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

后端 未结 13 794
渐次进展
渐次进展 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 08:01

    My configuration:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.14.+' // 0.14.1, 2014-11-6
        }
    }
    
    dependencies {
        compile 'com.android.support:multidex:1.0.0'
    }
    
    android {
        compileSdkVersion = 21
        buildToolsVersion = "21.1.0"
    
        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 21
            multiDexEnabled true
        }
    }
    

    Unfortunately, I have the same problem. But I found a strange situation:

    build/intermediates/dex/debug:

    -rw-rw-r--  1 andrew andrew  2221176 Nov  6 20:18 classes2.dex
    -rw-rw-r--  1 andrew andrew  8357596 Nov  6 20:18 classes.dex
    

    unzip apk, build/outputs/apk:

    -rw-rw-r-- 1 andrew andrew 8357596 Nov  6 20:18 classes2.dex
    -rw-rw-r-- 1 andrew andrew 2221176 Nov  6 20:18 classes.dex
    

    In apk, the main classes of classes.dex should be bigger than classes2.dex, but its not. I do also dex2jar & unzip jar to check classes, the application class is not there in classes.dex, its in classes2.dex contrarily.

    However, I should have fixed it. Here is my patched android gradle plugin you can try:

    buildscript {
        repositories {
            mavenCentral()
            maven { url 'https://github.com/yongjhih/android-gradle-plugin.m2/raw/master/' }
        }
        dependencies {
            classpath 'com.infstory.tools.build:gradle:0.14.+'
        }
    }
    

    The patch is in: https://github.com/yongjhih/android-gradle-plugin/commit/9c2212e3b1b4c6e1f7b47f2086aba1903a6258bf or https://android-review.googlesource.com/#/c/113331/

    issue: https://code.google.com/p/android/issues/detail?id=78761

    The official patch is https://android-review.googlesource.com/#/c/113201/ that already been merged, I think it might be fixed in next version.

    Already been fixed 0.14.2 (2014/11/10). (from http://tools.android.com/tech-docs/new-build-system)

    Release notes:
    
    0.14.2 (2014/11/10)
    
    Fix potential multi-dex issue where the dex files could be renamed during packaging, leading to the wrong main dex file being used.
    Fix versionNameSuffix support
    Fix BuildType.initWith to copy shrinkResources flag
    setup default proguard rule file if none are provided (SDK/tools/proguard/proguard-android.txt)
    BuildType.pseudoLocalesEnabled flag to include fake locales in apk.
    

提交回复
热议问题