'Unable to merge dex' 在依赖项中添加特定编译时 Android Studio 中的错误
'Unable to merge dex' error in Android Studio when adding a specific compile in dependencies
我正在尝试将一个特定的模块添加到我的 Android 项目中(这里的这个:https://github.com/danysantiago/sendgrid-android),但是虽然项目似乎可以正确构建,但当我在我尝试 运行 项目:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我可以确认是这个特定的模块导致了错误,因为如果我在 gradle:
中注释以下行,项目就可以正常工作
compile 'com.github.danysantiago:sendgrid-android:1'
到目前为止我尝试过的:
- 我已经清理并重建了项目。
- 将 multiDexEnabled true 添加到 android{defaultConfig{}}
- 将实现 'com.android.support:multidex:1.0.2' 添加到
依赖项{}
不幸的是,这些项目中的 none 有效,而且我无法在 Whosebug 上找到解决该问题的任何其他解决方案。如果您对此问题有任何帮助,我们将不胜感激!
在您的gradle
中更新
defaultConfig {
..............
multiDexEnabled true
}
dexOptions 应该添加..
dexOptions {
//incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
依赖添加
compile 'com.android.support:multidex:1.0.1'
也在你的 AndroidManifest.xml 添加这行 android:name
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>
您需要从库中排除 httpclient:
compile ('com.github.danysantiago:sendgrid-android:1'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
有一个新的 Android SendGrid 库利用了 Sendgrid 的 v3 API。
更新后的库消除了将旧库实现到针对较新 Android API 版本的应用程序时出现的问题。
库可以用jitpack导入
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.github.jakebreen:android-sendgrid:1.2.2'
}
我正在尝试将一个特定的模块添加到我的 Android 项目中(这里的这个:https://github.com/danysantiago/sendgrid-android),但是虽然项目似乎可以正确构建,但当我在我尝试 运行 项目:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我可以确认是这个特定的模块导致了错误,因为如果我在 gradle:
中注释以下行,项目就可以正常工作compile 'com.github.danysantiago:sendgrid-android:1'
到目前为止我尝试过的:
- 我已经清理并重建了项目。
- 将 multiDexEnabled true 添加到 android{defaultConfig{}}
- 将实现 'com.android.support:multidex:1.0.2' 添加到 依赖项{}
不幸的是,这些项目中的 none 有效,而且我无法在 Whosebug 上找到解决该问题的任何其他解决方案。如果您对此问题有任何帮助,我们将不胜感激!
在您的gradle
中更新 defaultConfig {
..............
multiDexEnabled true
}
dexOptions 应该添加..
dexOptions {
//incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
依赖添加
compile 'com.android.support:multidex:1.0.1'
也在你的 AndroidManifest.xml 添加这行 android:name
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>
您需要从库中排除 httpclient:
compile ('com.github.danysantiago:sendgrid-android:1'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
有一个新的 Android SendGrid 库利用了 Sendgrid 的 v3 API。 更新后的库消除了将旧库实现到针对较新 Android API 版本的应用程序时出现的问题。
库可以用jitpack导入
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.github.jakebreen:android-sendgrid:1.2.2'
}