Failed to verify dex: Bad method handle type 7

后端 未结 2 1459
攒了一身酷
攒了一身酷 2020-12-10 10:43

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 fu

相关标签:
2条回答
  • 2020-12-10 11:39

    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:

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    

    solution taken from here.

    0 讨论(0)
  • 2020-12-10 11:44

    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.

    0 讨论(0)
提交回复
热议问题