Android 错误:任务的执行失败:无法合并索引
错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。 java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 此错误是在更新到android 3.0后出现的 build.gradle(模块:app): 构建渐变(项目):Android 错误:任务的执行失败:无法合并索引,android,android-gradle-plugin,Android,Android Gradle Plugin,错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。 java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 此错误是在更新到android 3.0后出现的 build.gradle(模块:app): 构建渐变(项目): 这是因为您有重复的依赖项。您不能混合来自存储库和本地jar文件的相同依
这是因为您有重复的依赖项。您不能混合来自存储库和本地jar文件的相同依赖项。因此,你需要清理你的应用程序
build.gradle
。另外,不要对依赖项使用+
。使用精确版本的依赖项。这是因为如果不知道库的确切版本,则无法指定库的问题
您需要将build.gradle清理为以下内容:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.github.snowdream.android:smartimageview:0.0.2'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.mcxiaoke.volley:library-aar:1.0.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation files('libs/httpmime-4.3.jar')
//implementation files('libs/android-smart-image-view-1.0.0.jar')
implementation files('libs/activation.jar')
implementation files('libs/additionnal (1).jar')
//implementation files('libs/android-async-http-1.4.9.jar')
implementation files('libs/javamail-mailapi-1.4.2.jar')
implementation files('libs/javamail-smtp-1.4.2.jar')
implementation files('libs/mail (1).jar')
}
这是因为您有重复的依赖项。您不能混合来自存储库和本地jar文件的相同依赖项。因此,你需要清理你的应用程序
build.gradle
。另外,不要对依赖项使用+
。使用精确版本的依赖项。这是因为如果不知道库的确切版本,则无法指定库的问题
您需要将build.gradle清理为以下内容:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.github.snowdream.android:smartimageview:0.0.2'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.mcxiaoke.volley:library-aar:1.0.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation files('libs/httpmime-4.3.jar')
//implementation files('libs/android-smart-image-view-1.0.0.jar')
implementation files('libs/activation.jar')
implementation files('libs/additionnal (1).jar')
//implementation files('libs/android-async-http-1.4.9.jar')
implementation files('libs/javamail-mailapi-1.4.2.jar')
implementation files('libs/javamail-smtp-1.4.2.jar')
implementation files('libs/mail (1).jar')
}
要消除这个Dex问题,只需实现一个依赖项。 当我们使用来自同一服务器的多个不同服务时,会出现此问题。假设我们在一个项目中使用ads和Firestore,并且都有一个存储库maven。因此,我们需要在存储库上调用不同的数据,我们需要dex依赖关系来实现。 新的更新依赖项:-
implementation 'com.android.support:multidex:1.0.3'
我相信这会永久解决你的问题 要删除这个Dex问题,只需实现一个依赖项。 当我们使用来自同一服务器的多个不同服务时,会出现此问题。假设我们在一个项目中使用ads和Firestore,并且都有一个存储库maven。因此,我们需要在存储库上调用不同的数据,我们需要dex依赖关系来实现。 新的更新依赖项:-
implementation 'com.android.support:multidex:1.0.3'
我相信这会永久解决你的问题