Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

android - Failed to verify dex: Bad method handle type 7

I'm trying to create a test example where I've the contents of a TextView is set to the contents of a file stored in the IPFS.

I'm using this repository for my functions: https://github.com/ipfs/java-ipfs-api

I keep getting what appears to be a multidex error despit enable multidex in multiple places:

defaultConfig {
        applicationId "*****"
        minSdkVersion 26
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        **multiDexEnabled true**
    }

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

MainActivity.java:

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

This is the error I'm getting:

FATAL EXCEPTION: main
                                                                          Process: com.lab1.ac01220.blossom, PID: 20807
                                                                          java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lab1.ac01220.blossom/com.lab1.ac01220.blossom.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.lab1.ac01220.blossom.MainActivity" on path: DexPathList[[zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/base.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/lib/x86, /system/lib, /vendor/lib]]
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                                              at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                              at android.os.Looper.loop(Looper.java:164)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                           Caused by: java.lang.ClassNotFoundException: Didn't find class "com.lab1.ac01220.blossom.MainActivity" on path: DexPathList[[zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/base.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/lib/x86, /system/lib, /vendor/lib]]
                                                                              at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                              at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)?
                                                                              at android.app.ActivityThread.-wrap11(Unknown Source:0)?
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)?
                                                                              at android.os.Handler.dispatchMessage(Handler.java:105)?
                                                                              at android.os.Looper.loop(Looper.java:164)?
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6541)?
                                                                              at java.lang.reflect.Method.invoke(Native Method)?
                                                                              at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)?
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)?
05-01 17:51:48.094 20807-20807/com.lab1.ac01220.blossom E/AndroidRuntime:   Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
                                                                              at java.lang.VMClassLoader.findLoadedClass(Native Method)
                                                                              at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
                                                                                    ... 12 more
                                                                           Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/base.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/lib/x86, /system/lib, /vendor/lib]]
                                                                              at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                    ... 15 more
                                                                                Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_dependencies_apk.apk because: Failure to verify dex file '/data/app/com.lab1.ac01220.blossom-ixLs4xcrmWVVfgtCrH9vpw==/split_lib_dependencies_apk.apk': Bad method handle type 7
                                                                              at dalvik.system.DexFile.openDexFileNative(Native Method)
                                                                              at dalvik.system.DexFile.openDexFile(DexFile.java:353)
                                                                              at dalvik.system.DexFile.<init>(DexFile.java:100)
                                                                              at dalvik.system.DexFile.<init>(DexFile.java:74)
                                                                              at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
                                                                              at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
                                                                              at dalvik.system.DexPathList.<init>(DexPathList.java:157)
                                                                              at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.ja

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just experienced the same problem, it is because some library use Java 8 features, in your case it should be java-ipfs-api. To solve the problem, configure Android Gradle Plugin to support Java 8 by adding the following code to your build.gradle file, be sure to use latest Android gradle plugin:

android {
...
...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

solution taken from here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...