Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 project.After running the test project ,the main project ,classes and it's methods are not giving any errors but if any zxing framework class is utilyzed within that method of the main project there getting the above error at run time not yet compile time.Please tell me how to resolve this issue?

like image 1000
ADIT Avatar asked Jun 22 '12 11:06

ADIT


3 Answers

You are getting this error because of third party library reference added two times. You have added the application path in the build path of test project. so the library reference automatically added to test project". Remove any library reference in the test project under properties->android.

FYI, click here for detail explanation.

like image 99
Dasari Avatar answered Sep 20 '22 20:09

Dasari


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

like image 22
Hossein Shahdoost Avatar answered Sep 21 '22 20:09

Hossein Shahdoost


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.

like image 39
Jesús Castro Avatar answered Sep 18 '22 20:09

Jesús Castro