Email to Android Developers

Hi Taras,

Thank you so much for the detailed response.

I think you're right that when I run the Android project from Eclipse it both compiles the sources into classes and the classes into a dex file. I also agree that the most elegant way would be to add the translation step to the ADT plugin source code, thus enabling users to run Retrotranslator on the sources from within Eclipse. In some cases, such as mine, this is preferred over manually translating libraries that contain annotations and then adding them to the the main project (for instance, to simplify debugging).

There is a workaround to prevent classes that have already been translated by Retrotranslator to be recompiled from source. The workaround is to disable the Java Builders from within each project's properties. I tried this and no longer receive the Annotation error:

java.lang.Class.isAnnotationPresent(Class.java:1131)

However, I'm getting the error shown below (and listed on the full stack trace in 1). I took care to include retrotranslator-android-1.2.6.jar as an external library to all Tuscany projects, including calculator-android, as you pointed out. Additionally, I confirmed through the timestamps on class files and dex file that retrotranslated classes are not being recompiled and that the dex file was generated a few minutes after running retrotranslator.

java.lang.NoClassDefFoundError: net.sf.retrotranslator.android.main.java.lang._Class

I've tried this running retrotranslator as shown below, setting the target to java 1.5 at first and then to 1.4.

$ java -jar /../Retrotranslator-1.2.6-bin/retrotranslator-transformer-1.2.6.jar -srcdir /../workspace -target 1.5 -reflection safe -stripannot -classpath /../Retrotranslator-1.2.6-bin/retrotranslator-android-1.2.6.jar -verbose

What could be going wrong? Any suggestions would be greatly appreciated.

1 http://cwiki.apache.org/confluence/display/TUSCANYWIKI/14Jun2008

Email from Android Developers

Hi Oscar,

Unfortunately I cannot open the TUSCANY wiki at the moment but it looks like the contents of retrotranslator-android-1.2.6.jar hasn't been included into the dex file. Try to explicitly refer to it in your code, for instance, call
net.sf.retrotranslator.android.main.java.lang._Class.cast(String.class,
"test");

And you needn't use the 1.4 target - only using the 1.5 one makes sense for Android.

Cheers,
Taras.

Follow-up Email from Android Developers

I forgot to mention that you can use the embed option making inclusion
of retrotranslator-android-1.2.6.jar into the compile path redundant.

So you can add "-embed <a single dot or any package name>":

java -jar ../Retrotranslator-1.2.6-bin/retrotranslator-transformer-1.2.6.jar
-srcdir ../workspace -target 1.5 -reflection safe -stripannot -embed .
-classpath ../Retrotranslator-1.2.6-bin/retrotranslator-android-1.2.6.jar
-verbose

  • No labels