Unable to merge dex

前端 未结 30 2783
深忆病人
深忆病人 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条回答
  •  梦毁少年i
    2020-11-21 23:00

    Pay attention to Warnings!

    Sometimes you only need to eliminate warnings and the error will be disappeared automatically. See below special case:


    I had these two dependencies in my module-level build.gradle file:

    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    

    and Studio had warned (in addition to dex merging problem):

    All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 21.0.3. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:support-v4:21.0.3

    So I explicitly determined the version of com.android.support:support-v4 (see here for details) and both problems (the warning and the one related to dex merging) solved:

    implementation 'com.android.support:support-v4:27.0.2'  // Added this line (according to above warning message)
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    

    See below comments for other similar situations.

提交回复
热议问题