web-dev-qa-db-fra.com

Échec de la vérification de dex: type de descripteur de méthode incorrect 7

J'essaie de créer un exemple de test dans lequel le contenu d'un TextView est défini sur le contenu d'un fichier stocké dans l'IPFS.

J'utilise ce référentiel pour mes fonctions: https://github.com/ipfs/Java-ipfs-api

Je continue à avoir ce qui semble être une erreur multidex despit activer multidex à plusieurs endroits:

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

C'est l'erreur que j'obtiens:

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]

c'est mon code:

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

Edit: Je ne rencontrais pas cette erreur avant d’installer jitpack et Java-ipfs-api

7

Votre code n'a pas d'importance. L'erreur est " Impossible d'ouvrir les fichiers dex [...] Type de descripteur de méthode incorrect 7 ".

MethodHandleType est défini dans 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
  };

Par conséquent, dans votre cas, vous pouvez voir que l’une de vos méthodes est un invocateur pour une méthode directe (spéciale) (je suppose qu’elle se réfère à DMH ). Il a été ajouté dans commit 631827d .

À ce stade, je me demande si vous ne rencontrez pas de bogue dans le support technique de Java 8; car on ne s'attend pas à ce que quelque chose qui est désucré avec succès dans un dex ne s'exécute pas dans la technique. 

1
rds

Je viens de rencontrer le même problème, car certaines bibliothèques utilisent les fonctionnalités de Java 8; dans votre cas, il devrait s'agir de Java-ipfs-api. Pour résoudre le problème, configurez Android Gradle Plugin pour prendre en charge Java 8 en ajoutant le code suivant à votre fichier build.gradle. Assurez-vous d'utiliser le dernier plug-in Android Gradle:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

solution prise de ici .

4
lazybug