2017-12-03 151 views
0

我以前遇到過這個問題,並且能夠很容易地修復它。但是,這一次,我不明白是什麼原因造成的。自從它工作以來,對build.gradle的唯一改動是implementation project(':sharedfiles')--一個用於穿戴/移動的共享通用模塊。我沒有添加這個,我將該模塊添加爲依賴項,並且該行被自動添加,所以我懷疑它是一個錯誤。我有multipleDexEnabled true,無法找到任何衝突的依賴關係。任何幫助將不勝感激,這是我第一次使用通用模塊。這裏是兩個build.gradle文件。奇數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。如果實驗性功能無法正常工作,我將來可能需要它,但這是導致此問題的原因。