简体   繁体   中英

java.lang.VerifyError exception rejects class in package

I keep reading about the verifyError exception, but I can't seem to find a good solution for my problem.

The logs give me the following error:

Caused by: java.lang.VerifyError: Verifier rejected class mypackage.GraphThready: void mypackage.GraphThready.run() failed to verify: void mypackage.GraphThready.run(): [0x50BE] copy1 v2<-v398 type=Undefined cat=1 (declaration of 'mypackage.GraphThready' appears in /data/app/mypackage-2/split_lib_slice_9_apk.apk)

I don't know if it is because my class, mypackage.GraphThready is declared twice or perhaps the fact that I am testing my app on Android device with API 24(version number 7.0)

Here is what part of the app gradle file looks like:

compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
    applicationId "mypackage"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 2
    versionName "2.0"
    multiDexEnabled true

Perhaps I should change 'compiledSdkVersion' to 24? Any suggestions.

After much reading, updating and compiling my android app, I found out that I was not adding proper multi-dex support. It turns out all I had to do was increase the minSdkVersion in my gradle file to at least 21(Lollipop devices). According to the Android device Dashboard found here https://developer.android.com/about/dashboards/ about 10.3% of Android devices run KitKat which is a huge percentage of the lower level API's(<21). I am assuming is a world-wide figure not related to API level distribution in Android devices here in the USA, which is market where I will release the app. So, I changed minSdkVersion to 21 and kept the multiDexEnabled = true in the gradle file, and the error disappeared. For those that supporting pre-Lollipop devices and wish to add multi-dex support click here https://developer.android.com/studio/build/multidex It will show you exactly what to do, which is not very difficult.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM