So I'm trying to get Guice to run in my android maven project and bundle in a 3rd party module. It runs fine in the normal junittest that does a test injection, but fails on the VM with the logcat message attached below.
What I can't understand is that there are numerous reports of Guice working fine on android . Despite this, my code seems to be failing on getBeanInfo() being called from the Guice injector. It seems I'm not the only one having this error.
Is there a work around for the Android error "Unable to resolve virtual method java/beans/PropertyDescriptor"?
So I have a couple of questions. Is the reason Guice isn't working for me, because some functionality is being invoked by my 3rd party module that would fail everywhere but isn't common? Is there a way to get more info out of Guice as to what specifically is triggering the offending getBeanInfo()? Are there work arounds? What avenues are available to me for further debugging.
The solution must be maven compatible, as answers to a similar question about tweaking eclipse settings for similar problems can't apply. Getting "Caused by: java.lang.VerifyError:" (not that I got much mileage here anyway).
I think that all relevant files were processed by dx by the android maven plugin, as dependency:tree shows all relevant project at scope "compile", but I'm no expert here.
03-05 00:57:34.529: I/dalvikvm(2295): threadid=3: reacting to signal 3 03-05 00:57:34.568: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt' 03-05 00:57:35.059: I/dalvikvm(2295): threadid=3: reacting to signal 3 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): Could not load Finalizer in its own class loader. Loading Finalizer in the current class loader instead. As a result, you will not be able to garbage collect this class loader. To support reclaiming this class loader, either resolve the underlying issue, or move Google Collections to your system class path. 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): java.io.FileNotFoundException: com/google/inject/internal/util/$Finalizer.class 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue$DecoupledLoader.getBaseUrl(FinalizableReferenceQueue.java:269) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue$DecoupledLoader.loadFinalizer(FinalizableReferenceQueue.java:253) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue.loadFinalizer(FinalizableReferenceQueue.java:175) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue.(FinalizableReferenceQueue.java:100) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$QueueHolder.(MapMaker.java:787) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$WeakEntry.(MapMaker.java:946) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$Strength$1.newEntry(MapMaker.java:312) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.newEntry(MapMaker.java:498) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.newEntry(MapMaker.java:419) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2029) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.Annotations$AnnotationChecker.hasAnnotations(Annotations.java:116) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.Annotations.isScopeAnnotation(Annotations.java:124) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.ScopeBindingProcessor.visit(ScopeBindingProcessor.java:40) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.ScopeBindingProcessor.visit(ScopeBindingProcessor.java:30) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.spi.ScopeBinding.acceptVisitor(ScopeBinding.java:59) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.AbstractProcessor.process(AbstractProcessor.java:55) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:165) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.Guice.createInjector(Guice.java:95) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.Guice.createInjector(Guice.java:72) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.Guice.createInjector(Guice.java:62) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at za.co.mambo.cherrylist.android.CherryListActivity.onCreate(CherryListActivity.java:27) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.Activity.performCreate(Activity.java:4465) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.access$600(ActivityThread.java:123) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.os.Handler.dispatchMessage(Handler.java:99) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.os.Looper.loop(Looper.java:137) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.main(ActivityThread.java:4424) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at java.lang.reflect.Method.invokeNative(Native Method) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at java.lang.reflect.Method.invoke(Method.java:511) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at dalvik.system.NativeStart.main(Native Method) 03-05 00:57:35.108: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt' 03-05 00:57:35.338: D/dalvikvm(2295): GC_CONCURRENT freed 391K, 4% free 12676K/13127K, paused 8ms+5ms 03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;) 03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;) 03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;) 03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;) 03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;) 03-05 00:57:35.428: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;) 03-05 00:57:35.438: I/dalvikvm(2295): Could not find method java.beans.Introspector.getBeanInfo, referenced from method com.google.inject.internal.cglib.core.$ReflectUtils.getPropertiesHelper 03-05 00:57:35.438: W/dalvikvm(2295): VFY: unable to resolve static method 8989: Ljava/beans/Introspector;.getBeanInfo (Ljava/lang/Class;Ljava/lang/Class;)Ljava/beans/BeanInfo; 03-05 00:57:35.438: D/dalvikvm(2295): VFY: replacing opcode 0x71 at 0x000c 03-05 00:57:35.458: W/dalvikvm(2295): VFY: unable to resolve exception class 1373 (Ljava/beans/IntrospectionException;) 03-05 00:57:35.458: W/dalvikvm(2295): VFY: unable to find exception handler at addr 0x4e 03-05 00:57:35.458: W/dalvikvm(2295): VFY: rejected Lcom/google/inject/internal/cglib/core/$ReflectUtils;.getPropertiesHelper (Ljava/lang/Class;ZZ)[Ljava/beans/PropertyDescriptor; 03-05 00:57:35.458: W/dalvikvm(2295): VFY: rejecting opcode 0x0d at 0x004e 03-05 00:57:35.458: W/dalvikvm(2295): VFY: rejected Lcom/google/inject/internal/cglib/core/$ReflectUtils;.getPropertiesHelper (Ljava/lang/Class;ZZ)[Ljava/beans/PropertyDescriptor; 03-05 00:57:35.458: W/dalvikvm(2295): Verifier rejected class Lcom/google/inject/internal/cglib/core/$ReflectUtils; 03-05 00:57:35.488: D/AndroidRuntime(2295): Shutting down VM 03-05 00:57:35.498: W/dalvikvm(2295): threadid=1: thread exiting with uncaught exception (group=0x409c01f8) 03-05 00:57:35.508: I/dalvikvm(2295): threadid=3: reacting to signal 3 03-05 00:57:35.548: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt' 03-05 00:57:35.568: E/AndroidRuntime(2295): FATAL EXCEPTION: main 03-05 00:57:35.568: E/AndroidRuntime(2295): java.lang.RuntimeException: Unable to start activity ComponentInfo{za.co.mambo.cherrylist.android/za.co.mambo.cherrylist.android.CherryListActivity}: com.google.inject.internal.util.$ComputationException: java.lang.VerifyError: com/google/inject/internal/cglib/core/$ReflectUtils 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.access$600(ActivityThread.java:123) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.os.Handler.dispatchMessage(Handler.java:99) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.os.Looper.loop(Looper.java:137) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.main(ActivityThread.java:4424) 03-05 00:57:35.568: E/AndroidRuntime(2295): at java.lang.reflect.Method.invokeNative(Native Method) 03-05 00:57:35.568: E/AndroidRuntime(2295): at java.lang.reflect.Method.invoke(Method.java:511) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 03-05 00:57:35.568: E/AndroidRuntime(2295): at dalvik.system.NativeStart.main(Native Method) 03-05 00:57:35.568: E/AndroidRuntime(2295): Caused by: com.google.inject.internal.util.$ComputationException: java.lang.VerifyError: com/google/inject/internal/cglib/core/$ReflectUtils 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.FailableCache.get(FailableCache.java:50) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:125) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:521) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.Guice.createInjector(Guice.java:95) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.Guice.createInjector(Guice.java:72) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.Guice.createInjector(Guice.java:62) 03-05 00:57:35.568: E/AndroidRuntime(2295): at za.co.mambo.cherrylist.android.CherryListActivity.onCreate(CherryListActivity.java:27) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.Activity.performCreate(Activity.java:4465) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) 03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) 03-05 00:57:35.568: E/AndroidRuntime(2295): ... 11 more 03-05 00:57:35.568: E/AndroidRuntime(2295): Caused by: java.lang.VerifyError: com/google/inject/internal/cglib/core/$ReflectUtils 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.reflect.$FastClassEmitter.(FastClassEmitter.java:67) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:72) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:216) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:64) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.BytecodeGen.newFastClass(BytecodeGen.java:207) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:53) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:153) 03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal 03-05 00:57:36.178: I/dalvikvm(2295): threadid=3: reacting to signal 3 03-05 00:57:36.188: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt' 03-05 00:57:36.530: I/dalvikvm(2295): threadid=3: reacting to signal 3 03-05 00:57:36.538: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt'
The dalvik vm does not support aspected oriented programming so you can not use the plain JVM Guice. You have to use the no_aop version.
With a Maven build use
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<classifier>no_aop</classifier>
</dependency>
to get the no_aop jar into your build and apk.
Of course you can also look at using RoboGuice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With