Unable to merge dex

前端 未结 30 2656
深忆病人
深忆病人 2020-11-21 22:14

I have Android Studio Beta. I created a new project with compile my old modules but when I tried launching the app it did not launch with the message:

Error:         


        
相关标签:
30条回答
  • 2020-11-21 23:05

    if(1. Try to clean and rebuild work ) then good

    else if (2. Try to remove gradle work ) then good

    else-> 3. Try to add in grade.properties

    android.enableD8 = false
    

    else-> 4. Add multiDexEnabled true to your build.gradle

    android {
        compileSdkVersion 26
        defaultConfig {
          ...
            minSdkVersion 15
            targetSdkVersion 26
            multiDexEnabled true
         ...
        }
    }
    

    and add the dependency

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

    It may the first one works for u and so on but it really depends on the nature of your problem for me for example

    I got the error once I have added this library

    implementation 'com.jjoe64:graphview:4.2.2'
    

    and later I discovered that I have to check that and I have to add the same version of the support libraries. So I have to try another version

    compile 'com.jjoe64:graphview:4.2.1'
    

    and it fixes the problem. So pay attention for that.

    0 讨论(0)
  • 2020-11-21 23:05

    For our project, we accidentally added same jar two times with different name. Removing one of them solved the issue.

    0 讨论(0)
  • 2020-11-21 23:10

    In my case a library makes this problem, library was successfully added to project but when i run my app it shows me this error. So if this happens to you too, you can go to github and check issues or raise new issue. If you do not find any solution regarding the library i suggest you to replace it.

    0 讨论(0)
  • 2020-11-21 23:11

    Hi I have same issue tried almost everything. So, finally i resolved after 6 hour long struggle by debugging everything line by line.

    classpath 'com.google.gms:google-services:3.0.0'
    

    Google-services 3.0 Doesn't support firebase with Studio 3.0 with playServiceVersion: 11.6.0 or less.

    implementation "com.google.firebase:firebase-messaging:$rootProject.ext.playServiceVersion"
    implementation "com.google.firebase:firebase-core:$rootProject.ext.playServiceVersion"
    implementation "com.firebase:firebase-jobdispatcher-with-gcm-dep:$rootProject.ext.jobdispatcherVersion"
    

    Solution :

    I have change google services to

    classpath 'com.google.gms:google-services:3.1.1'
    

    And it support firebase services.

    Hopefully somebody save his/her time.

    0 讨论(0)
  • 2020-11-21 23:12
    1. Delete the .gradle directory.

    2. Run your app again.

    Notes

    • The .gradle directory is in your project's root folder. (You may have to show hidden files first.)
    • I have to do this every time I update a dependency module using Android 3.0. (More recent releases of Android Studio 3 seem to have resolved the problem.)
    0 讨论(0)
  • 2020-11-21 23:12
    1. Enable

      defaultConfig { multiDexEnabled true }

    2. If step 1 doesn't work then

      Go to project structure and find out the external library which is using a different version. Double click on it and delete its jar file. Close the project and open again android studio will rebuild the project. The problem should be gone.

    0 讨论(0)
提交回复
热议问题