【问题标题】:Unable to merge dex Android Studio 3.0.1无法合并dex Android Studio 3.0.1
【发布时间】:2017-11-30 11:15:20
【问题描述】:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

最近从 2.3.3 版本更新 Android Studio 3.0.1 后,我遇到了与 DexMergerException 相关的问题。

其他人也发布了与此相关的问题。但是在这个问题中,我想分析堆栈跟踪以找到相关的解决方案(因为我是这里的新手..)。

我无法解决它。

这是我的 build.gradle(Module:app)

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27

    defaultConfig {
        applicationId "com.aimnatvtz.aimatv"
        manifestPlaceholders = [onesignal_app_id: "MY_ONESIGNAL_APP_ID",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "226589149887"]

        minSdkVersion 16
        targetSdkVersion 27
        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'
        }
    }
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '25.3.0'
                }
            }
        }
    }

    implementation 'com.android.support:appcompat-v7:27.0.1'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:design:27.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'it.sephiroth.android.library.easing:android-easing:+'
    implementation 'com.facebook.android:facebook-login:4.27.0'
    implementation 'com.android.support:recyclerview-v7:27.0.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.github.bumptech.glide:glide:4.0.0'
    implementation 'com.google.android.gms:play-services-auth:11.6.2'
    implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
    implementation 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
    implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'

    testImplementation 'junit:junit:4.12'
}

【问题讨论】:

  • 尝试删除 build 文件夹并重建将完成的项目

标签: java android xml dex android-multidex


【解决方案1】:

已尝试启用多索引

修改你的 build.gradle

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

defaultConfig {
    multiDexEnabled true
}

在您的清单文件中定义您的应用程序名称属性,如下所示

android:name="com.pkg.YouApplication"

将其包含在您的应用程序类中

public class YouApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

}

【讨论】:

    【解决方案2】:

    我有同样的问题,它与更新有关 compile 'com.google.android.gms: play-services: 11.4.2compile' com.google.android.gms: play-services: 11.6.0 返回到旧版本的播放服务

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多