java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation getting while running test project?

后端 未结 9 1801
难免孤独
难免孤独 2020-11-29 06:37

I have implemented project by using third party library(zxing) after implementation project is working fine then after I have written one test project to unit test my projec

相关标签:
9条回答
  • 2020-11-29 06:54

    I changed test project setting in Intelij Idea. Go to Modules -> Dependencies, then set scope of the tested project to 'Provided'.

    0 讨论(0)
  • 2020-11-29 06:56

    I have this error sometimes. Just the build->clean project helped me

    0 讨论(0)
  • 2020-11-29 06:58

    It is because zxing jar files are being loaded twice, You must set the zxing library as "Provided" (if you are compiling your code using Maven) in compile time, so it does not add the library to your bytecode. that way you wouldn't get the error

    0 讨论(0)
  • 2020-11-29 06:59

    Unfortunately, the best solution which i have seen, it's to use a script with these code lines and using Espresso v2.0:

    adb shell setprop dalvik.vm.dexopt-flags v=n,o=v
    adb shell stop installd
    adb shell start installd
    

    Execute it before you begin to test. It's only necessary to do it once time.

    0 讨论(0)
  • 2020-11-29 06:59

    If you do not specifically need a device with low API version (<=19), you can leave transitive dependencies and create an emulator with higher API version.

    This happens only on devices which API is lower than Lollipop (API 21). Running tests on emulators higher/equal to API 21 runs normally, without issues.

    0 讨论(0)
  • 2020-11-29 07:00

    Uncheck the jars (in my case maps and google play services jar) from "Order and Export" tab under Project's Java build path in Eclipse.But let them be added in "Libraries" tab. Click OK, Clean projects and build now. It works.

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