What makes Guice unable to run on Android other than Guice-no-aop?

I see on the Guice download page a module called guice-no-aop, whose purpose is clearly aimed at Android developers. Several online queries have pulled out libraries like RoboGuice that look like they look like AOP based IoC, and some articles even provide great code examples.

But my question is: why doesn't Guice run in an Android app without these special libraries? I expected to find something on the Guice / wiki website, but, to my surprise, could not find a single reason.

Somebody knows?

Edit
The supporting question relates to the broader:

  • What other Java frameworks will not work on androids?!?! (What is the rule?)
+8
java android aop guice roboguice
source share
3 answers

This page contains several standard packages that are not supported. Anything that relies on these packages will most likely not work ...

Not supported . These packages, usually included in the standard version of the Java 2 platform, are not supported by Android.

  • java.applet
  • java.awt
  • java.beans
  • java.lang.management
  • java.rmi
  • javax.accessibility
  • javax.activity
  • javax.imageio
  • javax.management
  • javax.naming
  • javax.print
  • javax.rmi
  • javax.security.auth.kerberos
  • javax.security.auth.spi
  • javax.security.sasl
  • javax.swing
  • javax.transaction javax.xml (except javax.xml.parsers)
  • org.ietf. *
  • org.omg. *
  • org.w3c.dom. * (subpackages)

Also, as already mentioned, AOP based on encoding byte code at runtime will not work (not all, for example. Spring AOP ).

+3
source share

AOP is about to perform encoding of the byte code at runtime. The Dalvik machine on androids does not control the direct byte code of the JVM. They execute the translated version. I used and liked the Android version of Guice called roboguice. http://code.google.com/p/roboguice/ It does not perform any AOP, and your actions are inherited from a RoboGuice activity called RoboActivity, which makes an actual life-cycle injection of the activity at that time.

PS Most mocking frameworks also generate byte code and will not work or will not work fully.

+3
source share

Take a look at the comparison table here . It is for Guice 2.0 and 1.0, but it should still apply to Guice 3.

The main functional difference between Guice with and without AOP is the interceptor method. Based on the annotation you use in the method, that you bound as a guideline for processing annotations, guice will generate code at runtime to do what you intended. This is runtime code generation that Guice cannot do on Android since there is no API (yet) for generating dalvik bytecode on the fly.

+3
source share

All Articles