2017-12-03 16 views
0

この問題は以前から発生していて、かなり簡単に修正できました。しかし今回は、何が原因か分かりません。私が作ったbuild.gradleへの唯一の変更は、摩耗/モバイル用の共有共通モジュールimplementation project(':sharedfiles')でした。私はこれを追加せず、モジュールを依存関係として追加しました。この行は自動的に追加されたので、間違いはありません。私にはmultipleDexEnabled trueがあり、矛盾する依存関係は見つかりません。どんな助けもありがとう、これは私の初めての共通モジュールの使用です。ここには2つのbuild.gradleファイルがあります。Odd DexArchiveMergerException

モバイルモジュール

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    defaultConfig { 
     applicationId "bhprograms.supremis" 
     minSdkVersion 23 
     targetSdkVersion 26 
     multiDexEnabled true 
     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 fileTree(include: ['*.jar'], dir: 'libs') 
    implementation 'com.android.support:appcompat-v7:26.1.0' 
    implementation 'com.android.support.constraint:constraint-layout:1.0.2' 
    testImplementation 'junit:junit:4.12' 
    androidTestImplementation 'com.android.support.test:runner:1.0.1' 
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 
    wearApp project(':wear') 
    implementation 'com.google.android.gms:play-services-wearable:+' 
    implementation files('libs/gson.jar') 
    implementation project(':sharedfiles') 
} 

共通モジュール

apply plugin: 'com.android.library' 

android { 
    compileSdkVersion 26 



    defaultConfig { 
     minSdkVersion 23 
     targetSdkVersion 26 
     versionCode 1 
     multiDexEnabled true 
     minSdkVersion 23 
     targetSdkVersion 26 
     versionName "1.0" 

     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

} 

dependencies { 
    implementation fileTree(dir: 'libs', include: ['*.jar']) 

    implementation 'com.android.support:appcompat-v7:26.1.0' 
    testImplementation 'junit:junit:4.12' 
    androidTestImplementation 'com.android.support.test:runner:1.0.1' 
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 
    implementation files('libs/gson.jar') 
} 

そして、もちろん、エラーが発生しました。

Error:Execution failed for task ':mobile:transformDexArchiveWithExternalLibsDexMergerForDebug'. 
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex 

答えて

1

モバイルモジュールでimplementation files('libs/gson.jar')を取り除くことで解決しました。なぜこれが修正されたのか分かりません。なぜなら、モバイルモジュールでこのjarファイルをもう使用していなかったからです。実験的な機能がうまくいかない場合は、将来的に必要になるかもしれないので、そこに残しておきますが、これが原因です。

関連する問題