qdrzwd / dexmaker

Automatically exported from code.google.com/p/dexmaker
0 stars 0 forks source link

dexmaker-mockito gives "dalvikvm(1664): Could not find class 'android.app.LoaderManagerImpl'" on 4.3 #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. spend 20 years trying very hard to ignore Java
2. a friend needs an app - get on board Android - it rocks
3. Try to mock a stinkin' Activity in a unit test

What is the expected output? What do you see instead?

  mock(MainActivity.class) & spy(activity) both crash

  The sordid, agonizing details are here: http://stackoverflow.com/questions/19407513/mockitoexception-failed-to-mock-class-com-example-example-test-mainactivity

  aaand here: https://groups.google.com/d/msg/mockito/7GcAjTn4F2Y/IKsOTfgQrYMJ

  It's all just standard Android 4.3 stuff.

  Yes, I set the dexmaker.dexcache property to various /sdcard locations, _with_ write permission, etc

  The system hangs up for a long time, then spews:

    10-18 14:08:00.780: E/dalvikvm(1664): Could not find class 'android.app.LoaderManagerImpl', referenced from method MainActivity_Proxy.getLoaderManager
    10-18 14:08:01.089: E/dalvikvm(1664): Could not find class 'android.app.Activity$NonConfigurationInstances', referenced from method MainActivity_Proxy.retainNonConfigurationInstances

What version of the product are you using? On what operating system?

  When I DL Paul Butcher's example from http://paulbutcher.com/2012/05/15/mockito-on-android-step-by-step/ , it works correctly. Then when I generate a new app (in 2.2 or 4.3, with the older JARs or the latest jar), they all exhibit the same bug.

Please provide any additional information below.

  I also tried Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

  And I debugged into the source through Mockito into the first Dexmaker call, where the crash occurs, but I can't see it's source yet. I will try building Dexmaker next...

Original issue reported on code.google.com by phlip2...@gmail.com on 18 Oct 2013 at 7:39

GoogleCodeExporter commented 8 years ago
When I remove their jars and throw dexmaker & dexmaker-mockito's source into my 
/src folder, I get:

java.lang.VerifyError: org/mockito/cglib/core/ReflectUtils
at 
org.mockito.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:167)
at 
org.mockito.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrateg
y.java:25)
at 
org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java
:217)
at org.mockito.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:117)
at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:109)
at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:105)
at org.mockito.cglib.proxy.Enhancer.<clinit>(Enhancer.java:70)

...

Because this is a different error, I naturally don't know if this 
brain-transplant operation created a new bug, obscured the old bug, or just 
gave the old bug a different error messae.

Original comment by phlip2...@gmail.com on 19 Oct 2013 at 4:06