我知道这个问题已被多次询问,我搜索过但无法解决我的问题。我加上了
multiDexEnabled true
以及
implementation 'com.android.support:multidex:1.0.3'
正如一些答案建议但无法解决。任何人都可以帮助我,因为自从这个问题发生以来,我就被困住了。
错误是“错误:任务执行失败”:app:transformDexArchiveWithExternalLibsDexMergerForDebug'。
java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex`
我的build.gradle文件是
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.flashcardapp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:multidex:1.0.3'
//pin edittext library
implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
// glide
implementation 'com.github.bumptech.glide:glide:3.7.0'
//amazon aws
implementation 'com.amazonaws:aws-android-sdk-core:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.13'
implementation 'com.amazonaws:aws-android-sdk-s3:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.6.22'
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true }
implementation 'com.amazonaws:aws-java-sdk-s3:1.11.323'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
答案 0 :(得分:1)
在app / build.gradle中执行此操作:
android {
defaultConfig {
multiDexEnabled true
}
}
在此之后清理并重建您的项目。希望这有效:)
答案 1 :(得分:1)
我通过删除未使用的库然后清理并重建项目来解决它,正如Redman建议的那样。
答案 2 :(得分:0)
您可以通过将MaxHeapSize添加到gradle文件中来尝试此操作。
android {
...
dexOptions {
javaMaxHeapSize "4g"
}
}
我希望这可以帮助您解决问题。