web-dev-qa-db-ja.com

dexの検証に失敗しました:不正なメソッドハンドルタイプ7

TextViewのコンテンツがIPFSに保存されているファイルのコンテンツに設定されているテスト例を作成しようとしています。

私の機能にはこのリポジトリを使用しています: https://github.com/ipfs/Java-ipfs-api

私はmultidexのエラーのように見えるものを取得し続け、複数の場所で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をインストールする前にこのエラーが発生しませんでした

19

あなたのコードは重要ではありません。エラーは、「Failed to open dex files [...] Bad method handle type 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
  };

したがって、あなたのケースでは、メソッドの1つが直接(特別)メソッドの呼び出し元であることがわかります(私はそれを参照していると思います- [〜#〜] dmh [〜#〜] )。コミット 631827d で追加されました。

この時点で、Java 8 support)に関するアートのバグに遭遇していないのではないかと思います。dexで正常に脱糖されたものが、アート。

2
rds

同じ問題が発生したのは、一部のライブラリでJava 8つの機能が使用されているためです。あなたの場合はJava-ipfs-api。この問題を解決するには、Android Gradle Plugin to support Java 8 to add the following code to your build.gradleファイル、必ず最新のAndroid gradleプラグインを使用してください:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

here からの解。

38
lazybug