Didn't find class “android.support.multidex.MultiDexApplication” on path: DexPathList

后端 未结 13 717
渐次进展
渐次进展 2020-12-09 07:17

I\'m trying the new MultiDex Support on my app and so far I\'ve managed to compile my app correctly, but when running it, I get the following exception:



        
相关标签:
13条回答
  • 2020-12-09 07:40

    Very strange, I got same error message, but after I fixed some gradle lines it worked. Maybe it helps somebody:

    Project build.gradle:

    from:

    ..

    dependencies {
            // Android Gradle Plugin
            classpath 'com.android.tools.build:gradle:3.2.1'
            // Analytics
            **classpath 'com.google.gms:google-services:3.0.0'**
    }
    

    ..

    to: ..

    dependencies {
            // Android Gradle Plugin
            classpath 'com.android.tools.build:gradle:3.2.1'
            // Analytics
            **classpath 'com.google.gms:google-services:3.2.1'**
    }
    

    ..

    In the module build.gradle:

    from:

    ..

    dependencies {
        implementation 'com.android.support:multidex:1.0.3'
        implementation 'com.android.support:support-v4:26.1.0'
        implementation 'com.android.support:support-compat:26.1.0'
        implementation 'com.android.support:appcompat-v7:26.1.0'
        **implementation 'com.google.android.gms:play-services-analytics:12.0.1'**
    }
    

    ..

    to:

    ..

    dependencies {
        implementation 'com.android.support:multidex:1.0.3'
        implementation 'com.android.support:support-v4:26.1.0'
        implementation 'com.android.support:support-compat:26.1.0'
        implementation 'com.android.support:appcompat-v7:26.1.0'
        **implementation 'com.google.android.gms:play-services-analytics:16.0.5'**
    }
    

    ..

    There was no other changes in my code, but the fixed version worked on 4.x emulators too. Only the ** marked lines are changed.

    0 讨论(0)
  • 2020-12-09 07:41

    In my case its solved by changes below code in Manifest from

    android:name="android.support.multidex.MultiDexApplication"
    

    to

    android:name="androidx.multidex.MultiDexApplication"
    
    0 讨论(0)
  • 2020-12-09 07:42

    I was using the latest Android Studio and following the official document to add support to multidex https://developer.android.com/studio/build/multidex.html . But I still got the same exception. I spent a lot of time solving it. At last, I found the cause was I enabled "Java Exception Breakpoints - Any exception", and "Exception Breakpoints - When any is thrown". After I disabled them, the app ran without problems.

    Just follow the official document about multidex https://developer.android.com/studio/build/multidex.html . It works.

    0 讨论(0)
  • 2020-12-09 07:43

    This worked for me.

    File -> Sync Project with Grandle Files

    0 讨论(0)
  • 2020-12-09 07:43

    In my case I just changed the build.gradle and I leaved the AndroidManifest like that:

    android:name=".MainApplication"
    

    I am using React Native.

    0 讨论(0)
  • 2020-12-09 07:44

    For me, the answer was to switch to the androidx versions

    android:name="androidx.multidex.MultiDexApplication"

    implementation "androidx.multidex:multidex:2.0.1"

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