[英]Multi-feature Instant App crash issue
I am newbie to Instant app in android and following below link for reference: https://codelabs.developers.google.com/codelabs/android-instant-apps/#6 我是android中的Instant app的新手,请点击以下链接以供参考: https : //codelabs.developers.google.com/codelabs/android-instant-apps/#6
Installable apk and instant app with single feature is working fine. 具有单个功能的可安装APK和Instant App运行正常。
But when I am trying to run Multi- feature instant app it's getting crash(Following step - 7 from the above link). 但是,当我尝试运行多功能即时应用程序时,它会崩溃(遵循上述链接中的步骤7)。
Crash Report: 崩溃报告:
E: FATAL EXCEPTION: main
Process: com.bhaveshdesai.topekaapk, PID: 17609
java.lang.IncompatibleClassChangeError: Structural change of android.support.v4.app.Fragment is hazardous (/data/app/com.bhaveshdesai.topekaapk-PhiyPZ303gxpikP7GugKyA==/oat/x86/split_topekaui.odex at compile time, /data/app/com.bhaveshdesai.topekaapk-PhiyPZ303gxpikP7GugKyA==/oat/x86/base.odex at runtime): Virtual method count off: 111 vs 150
Landroid/support/v4/app/Fragment; (Compile time):
Static fields:
I ACTIVITY_CREATED
I CREATED
I INITIALIZING
I RESUMED
I STARTED
I STOPPED
.....
Feature Gradle File: Feature Gradle文件:
apply plugin: 'com.android.feature'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
dataBinding {
enabled true
}
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':topeka-base')
}
App Gradle File: 应用程式Gradle档案:
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//apply plugin: 'com.android.application'
apply plugin: 'com.android.feature'
android {
baseFeature = true
compileSdkVersion 26
buildToolsVersion "26.0.0"
dataBinding {
enabled = true
}
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
ext {
supportLibVersion = "25.4.0"
espressoVersion = "2.2.2"
androidTestVersion = "0.5"
hamcrestVersion = "1.3"
junitVersion = "4.12"
}
dependencies {
api "com.android.support:appcompat-v7:${supportLibVersion}"
api "com.android.support:cardview-v7:${supportLibVersion}"
api "com.android.support:design:${supportLibVersion}"
api "com.android.support:recyclerview-v7:${supportLibVersion}"
api "com.android.support.test.espresso:espresso-idling-resource:${espressoVersion}"
testApi "junit:junit:${junitVersion}"
androidTestApi("com.android.support.test.espresso:espresso-core:${espressoVersion}") {
exclude module: "espresso-idling-resource"
exclude group: "com.android.support"
}
androidTestApi("com.android.support.test.espresso:espresso-contrib:${espressoVersion}") {
exclude module: "espresso-core"
exclude module: "recyclerview-v7"
exclude group: "com.android.support"
}
androidTestApi("com.android.support.test:rules:${androidTestVersion}") {
exclude group: "com.android.support"
}
androidTestApi("com.android.support.test:runner:${androidTestVersion}") {
exclude group: "com.android.support"
}
androidTestApi "org.hamcrest:hamcrest-core:${hamcrestVersion}"
feature project(":topekaui")
application project(":topekaapk")
}
Please help me to solve this crash. 请帮助我解决此崩溃。
After so much try i found the problem. 经过这么多尝试,我发现了问题。
Problem is due to use android.support.v4.app.Fragment
问题是由于使用
android.support.v4.app.Fragment
After change android.support.v4.app.Fragment
to android.app.Fragment
its working. 将
android.support.v4.app.Fragment
更改为android.app.Fragment
其工作即可。
IncompatibleClassChangeError
typically happens when you make an incompatible binary change to the library and don't recompile the client code. 当您对库进行不兼容的二进制更改并且不重新编译客户端代码时,通常会发生
IncompatibleClassChangeError
。 See What causes java.lang.IncompatibleClassChangeError? 请参阅什么原因导致java.lang.IncompatibleClassChangeError? (but this might not be the real cause of your issue)
(但这可能不是造成您问题的真正原因)
After what step are you getting the crash? 在哪一步之后您会崩溃?
However, what I can see right now is that your Feature gradle file has the following dependency implementation project(':topeka-base')
, when it should contain api project(':topeka-base')
instead. 但是,我现在看到的是您的Feature gradle文件具有以下依赖项
implementation project(':topeka-base')
,而该文件应包含api project(':topeka-base')
。 (assuming that your Feature gradle = topeka-ui gradle) (假设您的Feature gradle = topeka-ui gradle)
topeka-ui/build.gradle
topeka-ui / build.gradle
Replace all pre-generated dependencies with the following dependency:
将所有预先生成的依赖项替换为以下依赖项:
dependencies { api project(':topeka-base') }
Please double check the codelab instructions to make sure you didn't miss any steps. 请仔细检查代码实验室说明,以确保您没有错过任何步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.