在路径 DexPathList 上未找到 class

Didn't find class on path DexPathList

我试图将我的项目更新到 targetSdk 23,但考虑到所有弃用,我决定我不适合它。我不想经历它,所以我在 mercurial 上恢复到旧版本,现在我得到的只是这个错误,我无法再次让该死的应用程序进入 运行。可能出了什么问题?

12-21 02:36:00.545      437-437/com.elgami.customizer E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.elgami.customizer, PID: 437
    java.lang.RuntimeException: Unable to instantiate application com.elgami.application.GlobalApplication: java.lang.ClassNotFoundException: Didn't find class "com.elgami.application.GlobalApplication" on path: DexPathList[[zip file "/data/app/com.elgami.customizer-1/base.apk"],nativeLibraryDirectories=[/data/app/com.elgami.customizer-1/lib/arm, /vendor/lib, /system/lib]]
            at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
            at android.app.ActivityThread.-wrap1(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.elgami.application.GlobalApplication" on path: DexPathList[[zip file "/data/app/com.elgami.customizer-1/base.apk"],nativeLibraryDirectories=[/data/app/com.elgami.customizer-1/lib/arm, /vendor/lib, /system/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at android.app.Instrumentation.newApplication(Instrumentation.java:981)
            at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
            at android.app.ActivityThread.-wrap1(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.elgami.customizer-1/base.apk
            at dalvik.system.DexFile.openDexFileNative(Native Method)
            at dalvik.system.DexFile.openDexFile(DexFile.java:295)
            at dalvik.system.DexFile.<init>(DexFile.java:80)
            at dalvik.system.DexFile.<init>(DexFile.java:59)
            at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
            at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
            at dalvik.system.DexPathList.<init>(DexPathList.java:120)
            at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
            at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
            at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
            at android.app.LoadedApk.getClassLoader(LoadedApk.java:376)
            at android.app.LoadedApk.makeApplication(LoadedApk.java:568)
            ... 9 more
    Suppressed: java.lang.ClassNotFoundException: com.elgami.application.GlobalApplication
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 12 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我的构建文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:21'
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "com.elgami.customizer"
        minSdkVersion 14
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            //runProguard false
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.ogaclejapan.smarttablayout:library:1.5.0@aar'
    compile 'com.github.antonyt:InfiniteViewPager:v1.0.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    // recyclerview
    compile 'com.android.support:recyclerview-v7:23.1.1'
    // google analytics
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    // pager sliding strip
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    // http library (for using beanstream REST)
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    // amaazon S3 uploads
    compile 'com.amazonaws:aws-android-sdk-s3:2.1.+'
    // paypal purchasing
    compile files('libs/PayPalAndroidSDK-2.7.1.jar')
    // Module dependency on ParseLoginUI library sources
    compile project(':ParseLoginUI')
    // Parse libs
    compile files('libs/ParseCrashReporting-1.9.2.jar')
    compile files('libs/Parse-1.9.1.jar')
    compile files('libs/ParseFacebookUtilsV4-1.9.1.jar')
    // android support v4
    compile files('libs/android-support-v4.jar')
    // facebook SDK
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    //butterknife
    compile 'com.jakewharton:butterknife:6.1.0'
    // Subsampling-scale-image-view (for templating)
    //compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.1.4'
    compile files('libs/AppRater.jar')
}

Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.

  1. 更改您的 Gradle 构建配置以启用 multidex
  2. 修改清单以引用 MultiDexApplication class

修改您的应用 Gradle 构建文件配置以包含支持库并启用 multidex 输出。

    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

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

更多详情可以访问