3

私はアンドロイドと参照用のリンクの下に、以下のインスタントアプリへの初心者です:単一機能で https://codelabs.developers.google.com/codelabs/android-instant-apps/#6多機能インスタントアプリのクラッシュ問題

インストール可能なAPKとインスタントアプリが正常に動作しています。

しかし、私がマルチフィーチャーインスタントアプリケーションを実行しようとしているとき、クラッシュしています(上記のリンクから7ステップ後)。

クラッシュレポート:

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 
    ..... 

機能の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') 
} 

アプリケーションの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") 
} 

P1のこのクラッシュを解決するのを手伝ってください。

答えて

5

そんなに試してみたら、問題が見つかりました。

問題はandroid.app.Fragmentその作業に変更android.support.v4.app.Fragmentandroid.support.v4.app.Fragment

を使用する予定です。

+0

これを再現できませんでした。あなたはバグを報告してから、ここにリンクすることができますか?それはすべてのために役立つだろう、ありがとう! https://issuetracker.google.com/issues/new?component=316045&template=1018787 –

2

IncompatibleClassChangeError通常、ライブラリに互換性のないバイナリを変更し、クライアントコードを再コンパイルしないと発生します。 What causes java.lang.IncompatibleClassChangeError?を参照してください(これは問題の本当の原因ではないかもしれません)

あなたはどのステップを踏んでいますか?

しかし、私が今見ることができるのは、あなたのフィーチャーグラデルファイルがimplementation project(':topeka-base')の代わりにapi project(':topeka-base')を含むはずであるということです。

dependencies { 
    api project(':topeka-base') 
} 

トピーカ-UI/build.gradle

依存以下 持つすべて事前に生成された依存関係を交換してください(あなたの機能のGradle =トピーカ-UIのGradleがあると仮定)コードラブの指示をもう一度確認して、何か踏み間違えがないことを確認してください。

+1

実装プロジェクト( ':topeka-base')を '' api project( ':topeka-base')に変更しましたが、同じエラーが発生します。 –