Не удалось проверить dex: дескриптор неправильного метода 7

Я пытаюсь создать тестовый пример, в котором содержимое TextView задано содержимым файла, хранящегося в IPFS.

Я использую этот репозиторий для своих функций: https://github.com/ipfs/java-ipfs-api

Я продолжаю получать то, что кажется многопользовательской ошибкой despit, позволяющей multidex в нескольких местах:

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);
    }

Это ошибка, которую я получаю:

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.java:65)
                                                                              at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
                                                                              at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
                                                                              at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
                                                                              at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
                                                                              at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:676)
                                                                              at android.app.LoadedApk.getClassLoader(LoadedApk.java:709)
                                                                              at android.app.LoadedApk.getResources(LoadedApk.java:936)
                                                                              at android.app.ContextImpl.createAppContext(ContextImpl.java:2242)
                                                                              at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5672)
                                                                              at android.app.ActivityThread.-wrap1(Unknown Source:0)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
                                                                                        ... 6 more
                                                                            [CIRCULAR REFERENCE: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]

это мой код:

TextView example = view.findViewById(R.id.example);
        IPFS ipfs = new IPFS("/ip4/127.0.0.1/tcp/4001");
        try {
            ipfs.refs.local();
            NamedStreamable.ByteArrayWrapper file = new NamedStreamable.ByteArrayWrapper("hello.txt", "G'day world! IPFS rocks!".getBytes());
            MerkleNode addResult = ipfs.add(file).get(0);
            Multihash filePointer = Multihash.fromBase58("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB");
            byte[] fileContents = ipfs.cat(filePointer);
            this.example.setText(new String(fileContents));
        } catch (IOException e) {
            e.printStackTrace();
        }

Изменить: я не получал эту ошибку до того, как установил jitpack и java-ipfs-api

Ответ 1

Ваш код не имеет значения. Ошибка: "Не удалось открыть файлы dex [...] Плохой дескриптор метода 7".

MethodHandleType определяется в art/libdexfile/dex/dex_file.h

  enum class MethodHandleType : uint16_t {  // private
    kStaticPut         = 0x0000,  // a setter for a given static field.
    kStaticGet         = 0x0001,  // a getter for a given static field.
    kInstancePut       = 0x0002,  // a setter for a given instance field.
    kInstanceGet       = 0x0003,  // a getter for a given instance field.
    kInvokeStatic      = 0x0004,  // an invoker for a given static method.
    kInvokeInstance    = 0x0005,  // invoke_instance : an invoker for a given instance method. This
                                  // can be any non-static method on any class (or interface) except
                                  // for "<init>".
    kInvokeConstructor = 0x0006,  // an invoker for a given constructor.
    kInvokeDirect      = 0x0007,  // an invoker for a direct (special) method.
    kInvokeInterface   = 0x0008,  // an invoker for an interface method.
    kLast = kInvokeInterface
  };

Следовательно, в вашем случае вы можете видеть, что один из ваших методов является invoker для прямого (специального) метода (я предполагаю, что это связано с DMH). Он был добавлен в commit 631827d.

На данный момент мне интересно, не попадаете ли вы в искусство вокруг поддержки java 8; потому что он не ожидал, что что-то, что было успешно отменено в dex, не может быть выполнено в данной области техники.

Ответ 2

Просто возникла та же проблема, потому что некоторые библиотеки используют функции Java 8, в вашем случае это должно быть java-ipfs-api. Чтобы решить эту проблему, настройте Android Gradle Plugin для поддержки Java 8, добавив следующий код в файл build.gradle, обязательно используйте последний плагин Android Gradle:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

решение взято из здесь.