Failed to verify dex: Bad method handle type 7

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.


Your code doesn't matter. The error is "Failed to open dex files [...] Bad method handle type 7".

MethodHandleType is defined in 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
  };

Hence, in your case, you can see that one of your method is an invoker for a direct (special) method (I guess it'referring to DMH). It was added in commit 631827d.

At this point, I'm wondering if you aren't hitting a bug in art around java 8 support ; because it's not expected that something that is desugared successfully in a dex fails to execute in the art.

Tags:

Android

Dex

Ipfs