将targetSdkVersion更改为28后获得java.lang.ClassNotFoundException错误

时间:2019-09-02 00:28:37

标签: java android

最近,我将Android项目从targetSdkVersion 26更改为28。我从Google Play收到了崩溃报告,出现“ java.lang.ClassNotFoundException ”错误

     java.lang.NoClassDefFoundError: 
   at com.google.android.vending.licensing.ServerManagedPolicy.decodeExtras (ServerManagedPolicy.java:266)
   at com.google.android.vending.licensing.ServerManagedPolicy.processServerResponse (ServerManagedPolicy.java:113)
   at com.google.android.vending.licensing.LicenseValidator.handleResponse (LicenseValidator.java:206)
   at com.google.android.vending.licensing.LicenseValidator.verify (LicenseValidator.java:166)
   at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run (LicenseChecker.java:242)
   at android.os.Handler.handleCallback (Handler.java:873)
   at android.os.Handler.dispatchMessage (Handler.java:99)
   at android.os.Looper.loop (Looper.java:214)
   at android.os.HandlerThread.run (HandlerThread.java:65)
 Caused by: java.lang.ClassNotFoundException: 
   at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
   at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
   at com.google.android.vending.licensing.ServerManagedPolicy.decodeExtras (ServerManagedPolicy.java:266)
   at com.google.android.vending.licensing.ServerManagedPolicy.processServerResponse (ServerManagedPolicy.java:113)
   at com.google.android.vending.licensing.LicenseValidator.handleResponse (LicenseValidator.java:206
   at com.google.android.vending.licensing.LicenseValidator.verify (LicenseValidator.java:166)
   at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run (LicenseChecker.java:242)
   at android.os.Handler.handleCallback (Handler.java:873)
   at android.os.Handler.dispatchMessage (Handler.java:99)
   at android.os.Looper.loop (Looper.java:214)
   at android.os.HandlerThread.run (HandlerThread.java:65)

我不知道发生了什么。任何帮助将不胜感激

在gradle.build中,添加了multiDexEnabled

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.0"   
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.myapptool"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        }
    buildTypes {
        release {
            minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:recyclerview-v7:28.0.0'     
    compile 'com.android.support:design:28.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile files('libs/achartengine-1.2.0.jar')
    compile project(':filemanager')
    compile project(':moreapp')
    compile files('libs/log4j-1.2.15.jar')
    compile 'de.hdodenhof:circleimageview:2.1.0'

    compile 'com.android.support:multidex:1.0.1'

}

1 个答案:

答案 0 :(得分:0)

这似乎是与multidex相关的问题。请在gradle.build

中启用multidex
 defaultConfig {
 // Enabling multidex support.
 multiDexEnabled true
}

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