Android Studio 3.0 Execution failed for task: unable to merge dex

前端 未结 26 3325
野性不改
野性不改 2020-11-27 11:52

android studio was getting build error while build execution with following:

Error:Execution failed for task \':app:transformDexArchiveWithExternalLi

相关标签:
26条回答
  • 2020-11-27 11:59

    Same problem. I have enabled multidex: defaultConfig { applicationId "xxx.xxx.xxxx" minSdkVersion 24 targetSdkVersion 26 multiDexEnabled true

    I have cleared cache, ran gradle clean, rebuild, make, tried to make sure no conflicts in imported libraries (Removed all transitive dependencies) and made all updates. Still:

    Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

    Turns out the build did not like: implementation 'org.slf4j:slf4j-android:1.7.21'

    0 讨论(0)
  • 2020-11-27 11:59

    This is what works for me. clean prepare and run.

    cordova clean android;
    ionic cordova prepare andriod;
    ionic cordova run andriod;
    

    hope it helps.

    0 讨论(0)
  • 2020-11-27 12:00

    Try to add this in gradle

        android {
          defaultConfig {
            multiDexEnabled true
            }
       }
    
    0 讨论(0)
  • 2020-11-27 12:02

    Same thing happened to me, figured out that I was in the middle of updating to AS 3.0.1 and after I did the update, cleaned and rebuilt the app, everything was fixed.

    0 讨论(0)
  • 2020-11-27 12:04

    This error happens when you add an external library which may not be compatible with your compileSdkVersion .

    Be careful when you are adding an external library.

    I spent 2 days on this problem and finally it got solved following these steps.

    • Make sure all your support libraries are same as compileSdkVersion of your build.gradle(Module:app) in my case it is 26.

    • In your defaultConfig category type multiDexEnabled true. This is the important part.

    • Go to File | Settings | Build, Execution, Deployment | Instant Run and try to Enable/Disable Instant Run to hot swap... and click okay

    • Sync Your project.

    • Lastly, Go to Build | click on Rebuild Project.

    • Note: Rebuild Project first cleans and then builds the project.

    0 讨论(0)
  • 2020-11-27 12:05

    Also be sure your app is subclassing MultiDexApplication

    import android.support.multidex.MultiDexApplication
    
    class App : MultiDexApplication()
    

    or if not subclassing Application class, add to AndroidManifest.xml

    <application
      android:name="android.support.multidex.MultiDexApplication"
    
    0 讨论(0)
提交回复
热议问题