没有在路径上找到类...:DexPathList处于发布模式

时间:2016-07-06 08:41:50

标签: android android-gradle build.gradle multidex android-multidex

我们有一个相对较小的Android项目(移动和磨损),我们在发布模式下构建时遇到麻烦。 移动应用抛出的例外是:

/AndroidRuntime: FATAL EXCEPTION: Thread-766
Process: com.[OURAPP], PID: 9986
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/JsonParser;
    at com.[OURAPP].Login.LoginRefresher$1HttpRefresher.run(LoginRefresher.java:134)
    at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.gson.JsonParser" on path: DexPathList[[zip file "/data/app/com.[OURAPP]-1/base.apk"],nativeLibraryDirectories=[/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 com.[OURAPP].Login.LoginRefresher$1HttpRefresher.run(LoginRefresher.java:134) 
    at java.lang.Thread.run(Thread.java:818) 
                    Suppressed: java.lang.ClassNotFoundException: com.google.gson.JsonParser
    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)
                                              ... 3 more
 Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Multidexing出了问题。我到处寻找解决方案,我无法真正看到我们做错了什么。我们使用gradle 2.14,移动项目的build.gradle文件如下所示。

apply plugin: 'com.android.application'

android {
    useLibrary 'org.apache.http.legacy'
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "com.[OURAPP]"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode buildVersionCode()
        versionName version
        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

dependencies {
    compile fileTree( include: ['*.jar'],dir: 'libs')
    wearApp project(':wear')
    compile project(':common')
    testCompile 'junit:junit:4.12'
    compile project(':syncservice')
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.auth0.android:lock:1.13.+'
    compile 'com.auth0.android:lock-facebook:2.4.+'
    //compile 'com.auth0.android:lock-googleplus:2.0.+'
    compile 'net.danlew:android.joda:2.9.2'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'org.greenrobot:eventbus:3.0.0' 
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:percent:23.0.0'

}

apply plugin: 'com.google.gms.google-services'

内置调试模式时不会发生错误。如果minSDKVersion设置为19,则不会发生错误,但这不是真正的修复。

我们有

@Override
protected void attachBaseContext(Context base)
{
    super.attachBaseContext(base);
    MultiDex.install(this);
}

在我们的主要应用程序类中。

我正在使用

从命令行构建
gradlew clean assembleRelease -Pandroid.injected.signing.store.file=Release\releaseKeyStore.jks -Pandroid.injected.signing.store.password=[PASS]-Pandroid.injected.signing.key.alias="[OURAPP} android release key" -Pandroid.injected.signing.key.password=[PASS]” 

如果有人能告诉我如何调试这种错误会有很大的帮助,因为我觉得外界可能很难告诉我们究竟做错了什么,但任何提示都会受到赞赏。

0 个答案:

没有答案