How do i build with Ant?

527 views
Skip to first unread message

Joersch

unread,
Nov 22, 2011, 7:04:41 AM11/22/11
to androidannotations
Hello,
androidannotations works really fine with the eclipse plugin. I have
to setup up my own build process with ant.
How can i automatically generate / integrate the androidannotations
with ant?

thanks
joersch

(cool project!)

Pierre-Yves Ricau

unread,
Nov 24, 2011, 2:28:13 AM11/24/11
to androidan...@googlegroups.com
Hello !

That a really interesting question. I haven't had any report of anyone using AndroidAnnotations with Ant yet, so I don't know if it has already been done. We documented how to use Maven, and how to do it from Eclipse, but I think we should definitely document how to use it with Ant, since Android projects come with an Ant task when you create them.

The question we are trying to solve here is : "how to run a java 6 Annotation Processor with Ant", and "how to integrate that in the Android Ant tasks".

Basically, running an annotation processor involves giving additional arguments to javac.


I don't really know how to integrate that in an Android Ant script, because I'm not an Ant expert ;-) . Please let us know what you find out, if it works or not and why ;-) . And if anyone else can help, of course that's welcome!

Thanks for using AndroidAnnotations

2011/11/22 Joersch <uhlman...@googlemail.com>



--
Pierre-Yves Ricau


Joersch

unread,
Nov 24, 2011, 8:01:12 AM11/24/11
to androidannotations
Hello Pierre,
i dont write any special Ant-Task by my self, but i know how can it
integrate and call it.

To finally build the *.apk via ant, call the ant target release (type
in command line: ant release). These Task calls the "-pre-build"
target, that you can override in your own build.xml file (or any other
importet *.xml file). Now you have the correct point for generating.

To define a self made ant task is follows to do:
In build.xml define the path to the self written anttask
<path id="androidannotations.antlibs">
<pathelement path="${jar.libs.dir}/
androidannotations-2.1.2.jar" />
</path>

Then define the new Ant Task itself with the new Name
"annotateandroid":
<taskdef name="annotateandroid"

classname="com.googlecode.androidannotations.AnnotationBuilderTask"
classpathref="androidannotations.antlibs" />

Call this task in build.xml:
<target name="-pre-build">
<echo>--------------------------------------------</
echo>
<echo>----------------- Annotate now------</echo>
<echo>--------------------------------------------</
echo>
<annotateandroid/>
</target>

The "com.googlecode.androidannotations.AnnotationBuilderTask" class
inherits from org.apache.tools.ant.Task
In this class can all generating code implementet.

Here is an tutorial to writing Ant-Tasks:
http://ant.apache.org/manual/index.html

Is there everybody they can write such ant-task? It would by realy
useful.

Regards
joersch

On 24 Nov., 08:28, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> Hello !
>
> That a really interesting question. I haven't had any report of anyone
> using AndroidAnnotations with Ant yet, so I don't know if it has already
> been done. We documented how to use Maven, and how to do it from Eclipse,
> but I think we should definitely document how to use it with Ant, since
> Android projects come with an Ant task when you create them.
>
> The question we are trying to solve here is : "how to run a java 6
> Annotation Processor with Ant", and "how to integrate that in the Android
> Ant tasks".
>
> Basically, running an annotation processor involves
> giving additional arguments to javac.
>

> It seems that someone found a general solution here :http://stackoverflow.com/questions/3644069/java-6-annotation-processi...


>
> I don't really know how to integrate that in an Android Ant script, because
> I'm not an Ant expert ;-) . Please let us know what you find out, if it
> works or not and why ;-) . And if anyone else can help, of course that's
> welcome!
>
> Thanks for using AndroidAnnotations
>

> 2011/11/22 Joersch <uhlmann.jo...@googlemail.com>

Piwaï

unread,
Dec 28, 2011, 12:11:15 PM12/28/11
to androidannotations
Here is an interesting comment regarding how to configure Ant with
AndroidAnnotations: http://code.google.com/p/androidannotations/issues/detail?id=153#c1

Joersch

unread,
Jan 11, 2012, 10:23:57 AM1/11/12
to androidannotations
Hello,
i read this. This issnt work for me. I think it solves only a problem,
if the code is allready successfull generated.
But the code have to generate via ant before the compile task is
executed. this issnt done with this example.

Does it is possible the project member mat.boni...@gmail.com describe
how they are build they project with ant?

joersch

Pierre-Yves Ricau

unread,
Jan 11, 2012, 11:44:25 AM1/11/12
to androidan...@googlegroups.com
Hello Joersch,

Mathieu Boniface wrote a detailed documentation here: https://github.com/excilys/androidannotations/wiki/Building-Project-Ant

Does it help?

Also notice that AndroidAnnotations has moved to GitHub (https://github.com/excilys/androidannotations), and that we are trying to write recipes for AndroidAnnotations in a dedicated Cookbook: https://github.com/excilys/androidannotations/wiki/Cookbook

Cheers,
Piwaï

2012/1/11 Joersch <uhlman...@googlemail.com>

Joersch

unread,
Jan 12, 2012, 5:30:20 AM1/12/12
to androidannotations
Hello Piwaï,
no, unfortunately not. I read this also, it describe only if the code
is generated done. The code generation process itself isnt implemented
in this code snipped.

regards
joersch


On 11 Jan., 17:44, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> Hello Joersch,
>
> Mathieu Boniface wrote a detailed documentation here:https://github.com/excilys/androidannotations/wiki/Building-Project-Ant
>
> Does it help?
>
> Also notice that AndroidAnnotations has moved to GitHub (https://github.com/excilys/androidannotations), and that we are trying to
> write recipes for AndroidAnnotations in a dedicated Cookbook:https://github.com/excilys/androidannotations/wiki/Cookbook
>
> Cheers,
> Piwaï
>
> 2012/1/11 Joersch <uhlmann.jo...@googlemail.com>

Pierre-Yves Ricau

unread,
Jan 12, 2012, 5:37:51 AM1/12/12
to androidan...@googlegroups.com
Well, I'm not sure I understood everything correctly, but just to make things clear :

- In AndroidAnnotations, the code generation process IS part of the compilation. We use the standard Java 6 annotation processing API, and the annotation processing is done when javac is executed.
- That's why you only need to update the compile task to add a parameter to javac, to let it know that it should use our annotation processor when compiling the project classes.

2012/1/12 Joersch <uhlman...@googlemail.com>

Joersch

unread,
Jan 18, 2012, 1:38:42 PM1/18/12
to androidannotations
Hello Piwaï

On 12 Jan., 11:37, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> - In AndroidAnnotations, the code generation process IS part of the
> compilation. We use the standard Java 6 annotation processing API, and the
> annotation processing is done when javac is executed.

ok, that is true.

> - That's why you only need to update the compile task to add a parameter to
> javac, to let it know that it should use our annotation processor when
> compiling the project classes.

perhaps, it is not enough.
I figure out as describe before, but i get compile errors.
first errors i get is
\src\x\y\z\MyActivity.java:18: cannot find symbol
import x.y.z.MyActivity_;

(the underscore version of this class) ok, i understand it is not
generated at this moment.

the next i read is an echo:
[javac] Note: Starting AndroidAnnotations annotation processing

ok, fine, the annotation processor is now startet, but i get the next
error:
[javac] Note: Dummy source file: file:///....bin/classes/dummy1326910825123.java
[javac] Note: AndroidManifest.xml file found: AndroidManifest.xml
[javac]
[javac]
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.NoClassDefFoundError: android/view/View

do you have an idea, what can i do that i can generate the source at
the right moment?
thanks very much
joersch

>
> 2012/1/12 Joersch <uhlmann.jo...@googlemail.com>

Pierre-Yves Ricau

unread,
Jan 18, 2012, 5:27:52 PM1/18/12
to androidan...@googlegroups.com
I think it would be easier if you sent us the whole console ouput :)

I think the heart of the problem is here :

 [javac] An annotation processor threw an uncaught exception.
 [javac] Consult the following stack trace for details.
 [javac] java.lang.NoClassDefFoundError: android/view/View

Do you have the rest of the stacktrace ?

2012/1/18 Joersch <uhlman...@googlemail.com>

Joersch

unread,
Jan 19, 2012, 7:45:50 AM1/19/12
to androidannotations
Hello Pierre,
yes, i have the rest of the stack trace. (I dont push it, becauce i
reduce it to the essentials)

here is it:
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.NoClassDefFoundError: android/view/ViewGroup
[javac] at java.lang.ClassLoader.defineClass1(Native Method)
[javac] at
java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
[javac] at java.lang.ClassLoader.defineClass(ClassLoader.java:
615)
[javac] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
141)
[javac] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
[javac] at java.net.URLClassLoader.access
$000(URLClassLoader.java:58)
[javac] at java.net.URLClassLoader$1.run(URLClassLoader.java:
197)
[javac] at java.security.AccessController.doPrivileged(Native
Method)
[javac] at
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[javac] at java.lang.ClassLoader.loadClass(ClassLoader.java:
306)
[javac] at java.lang.ClassLoader.loadClass(ClassLoader.java:
247)
[javac] at java.lang.Class.forName0(Native Method)
[javac] at java.lang.Class.forName(Class.java:169)
[javac] at
com.googlecode.androidannotations.internal.codemodel.JCodeModel.ref(JCodeModel.java:
378)
[javac] at
com.googlecode.androidannotations.processing.EBeanHolder.refClass(EBeanHolder.java:
53)
[javac] at
com.googlecode.androidannotations.processing.ViewByIdProcessor.process(ViewByIdProcessor.java:
69)
[javac] at
com.googlecode.androidannotations.processing.ModelProcessor.process(ModelProcessor.java:
48)
[javac] at
com.googlecode.androidannotations.AndroidAnnotationProcessor.processAnnotations(AndroidAnnotationProcessor.java:
399)
[javac] at
com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:
286)
[javac] at
com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:
259)
[javac] at
com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:
627)
[javac] at
com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:
556)
[javac] at
com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:
701)
[javac] at
com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:
987)
[javac] at
com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:
353)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:
279)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:
270)
[javac] at com.sun.tools.javac.Main.compile(Main.java:69)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[javac] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
[javac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[javac] at java.lang.reflect.Method.invoke(Method.java:597)
[javac] at
org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:
56)
[javac] at
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1097)
[javac] at
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:906)
[javac] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
Source)
[javac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[javac] at java.lang.reflect.Method.invoke(Method.java:597)
[javac] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:
106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
[javac] at com.android.ant.IfElseTask.execute(IfElseTask.java:
120)
[javac] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
Source)
[javac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[javac] at java.lang.reflect.Method.invoke(Method.java:597)
[javac] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:
106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
[javac] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
Source)
[javac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[javac] at java.lang.reflect.Method.invoke(Method.java:597)
[javac] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:
106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:
398)
[javac] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
Source)
[javac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[javac] at java.lang.reflect.Method.invoke(Method.java:597)
[javac] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:
106)
[javac] at org.apache.tools.ant.Task.perform(Task.java:348)
[javac] at org.apache.tools.ant.Target.execute(Target.java:
390)
[javac] at
org.apache.tools.ant.Target.performTasks(Target.java:411)
[javac] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
[javac] at
org.apache.tools.ant.Project.executeTarget(Project.java:1329)
[javac] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:
41)
[javac] at
org.apache.tools.ant.Project.executeTargets(Project.java:1212)
[javac] at org.apache.tools.ant.Main.runBuild(Main.java:801)
[javac] at org.apache.tools.ant.Main.startAnt(Main.java:218)
[javac] at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[javac] at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[javac] Caused by: java.lang.ClassNotFoundException:
android.view.ViewGroup
[javac] at java.net.URLClassLoader$1.run(URLClassLoader.java:
202)
[javac] at java.security.AccessController.doPrivileged(Native
Method)
[javac] at
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[javac] at java.lang.ClassLoader.loadClass(ClassLoader.java:
306)
[javac] at java.lang.ClassLoader.loadClass(ClassLoader.java:
247)
[javac] ... 74 more

joersch


On 18 Jan., 23:27, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> I think it would be easier if you sent us the whole console ouput :)
>
> I think the heart of the problem is here :
>
>  [javac] An annotation processor threw an uncaught exception.
>  [javac] Consult the following stack trace for details.
>  [javac] java.lang.NoClassDefFoundError: android/view/View
>
> Do you have the rest of the stacktrace ?
>
> 2012/1/18 Joersch <uhlmann.jo...@googlemail.com>

Pierre-Yves Ricau

unread,
Jan 19, 2012, 8:37:50 AM1/19/12
to androidan...@googlegroups.com
Thanks.

This errors occurs in CodeModel, which we use to generate the code. The following code in com.sun.codemodel.JCodeModel.ref(String) is at fault :

        // then the default mechanism.

        try {

            return ref(Class.forName(fullyQualifiedClassName));

        } catch (ClassNotFoundException e1) {

            // fall through

        }

As you can see, it catches ClassNotFoundException but not NoClassDefFoundError, which you happen to have.

Could you please let us know what version of Java and Ant you use, and also copy & paste your build.xml ?

2012/1/19 Joersch <uhlman...@googlemail.com>

Joersch

unread,
Jan 19, 2012, 9:47:21 AM1/19/12
to androidannotations
yes, my used version is:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)

Apache Ant version 1.8.0 compiled on February 1 2010

joersch


On 19 Jan., 14:37, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> Thanks.
>
> This errors occurs in CodeModel, which we use to generate the code. The
> following code in com.sun.codemodel.JCodeModel.ref(String) is at fault :
>
>         // then the default mechanism.
>
>         try {
>
>             return ref(Class.forName(fullyQualifiedClassName));
>
>         } catch (ClassNotFoundException e1) {
>
>             // fall through
>
>         }
> As you can see, it catches ClassNotFoundException but not NoClassDefFoundError,
> which you happen to have.
>
> Could you please let us know what version of Java and Ant you use, and also
> copy & paste your build.xml ?
>
> 2012/1/19 Joersch <uhlmann.jo...@googlemail.com>
> ...
>
> Erfahren Sie mehr »

Joersch

unread,
Jan 19, 2012, 10:01:31 AM1/19/12
to androidannotations
the included staging.xml file is used to stage the compiled version.
the build.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<project name="MyProjekt" default="help">
<import file="staging.xml"/>
<property name="verbose" location="yes" />


<!-- The local.properties file is created and updated by the
'android' tool.
It contains the path to the SDK. It should *NOT* be checked
into
Version Control Systems. -->
<loadproperties srcFile="local.properties" />

<!-- The ant.properties file can be created by you. It is only
edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build
properties.
Here are some properties you may want to change/update:

source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.

For other overridable properties, look at the beginning of
the rules
files in the SDK, at tools/ant/build.xml

Properties related to the SDK location or the project target
should
be updated using the 'android' tool with the 'update' action.

This file is an integral part of the build system for your
application and should be checked into Version Control
Systems.

-->
<property file="ant.properties" />

<!-- The project.properties file is created and updated by the
'android'
tool, as well as ADT.

This contains project specific properties such as project
target, and library
dependencies. Lower level build properties are stored in
ant.properties
(or in .classpath for Eclipse projects).

This file is an integral part of the build system for your
application and should be checked into Version Control
Systems. -->
<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate
local.properties using 'android update project'"
unless="sdk.dir"
/>


<!-- extension targets. Uncomment the ones where you want to do custom
work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>

/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override $
{out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->

<!-- Import the actual build file.

To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the
top node)
into this file, replacing the <import> task.
- customize to your needs.

***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below
to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools
such as "android update project"
-->
<!-- version-tag: 1 -->


<!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-build-setup, -pre-build, -code-
gen, -pre-compile">
<echo>### compiliere #################</echo>
<do-only-if-manifest-hasCode elseText="hasCode = false.
Skipping...">
<!-- If android rules are used for a test project, its
classpath should include
tested project's location -->
<condition property="extensible.classpath"
value="${tested.project.absolute.dir}/bin/classes"
else=".">
<isset property="tested.project.absolute.dir" />
</condition>
<condition property="extensible.libs.classpath"
value="${tested.project.absolute.dir}/$
{jar.libs.dir}"
else="${jar.libs.dir}">
<isset property="tested.project.absolute.dir" />
</condition>
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs=""
destdir="${out.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
verbose="${verbose}"
classpath="${extensible.classpath}"
classpathref="jar.libs.ref"
>
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<classpath>
<fileset dir="compile-libs" includes="*.jar"/>
<fileset dir="${extensible.libs.classpath}"
includes="*.jar" />
</classpath>
</javac>
<!-- if the project is a library then we generate a jar
file -->
<if condition="${project.is.library}">
<then>
<echo>Creating library output jar file...</echo>
<property name="out.library.jar.file" location="$
{out.absolute.dir}/classes.jar" />
<if>
<condition>
<length string="$
{android.package.excludes}" trim="true" when="greater" length="0" />
</condition>
<then>
<echo>Custom jar packaging exclusion: $
{android.package.excludes}</echo>
</then>
</if>
<jar destfile="${out.library.jar.file}">
<fileset dir="${out.classes.absolute.dir}"
excludes="**/R.class **/R$*.class"/>
<fileset dir="${source.absolute.dir}"
excludes="**/*.java ${android.package.excludes}" />
</jar>
</then>
</if>

<!-- if the project is instrumented, intrument the classes
-->
<if condition="${build.is.instrumented}">
<then>
<echo>Instrumenting classes from $
{out.absolute.dir}/classes...</echo>
<!-- It only instruments class files, not any
external libs -->
<emma enabled="true">
<instr verbosity="${verbosity}"
mode="overwrite"
instrpath="${out.absolute.dir}/classes"
outdir="${out.absolute.dir}/classes">
</instr>
<!-- TODO: exclusion filters on R*.class and
allowing custom exclusion from
user defined file -->
</emma>
</then>
</if>
</do-only-if-manifest-hasCode>
</target>


<import file="${sdk.dir}/tools/ant/build.xml" />

</project>
> ...
>
> Erfahren Sie mehr »

Pierre-Yves Ricau

unread,
Jan 20, 2012, 2:37:25 AM1/20/12
to androidan...@googlegroups.com
I'm not an Ant expert, I didn't see anything that looks like a problem. Maybe mat.boniface will have other ideas ?

Meanwhile, I created an issue, and we are going to take care of that CodeModel bug: https://github.com/excilys/androidannotations/issues/71

Hopefully it should solve your problem.

2012/1/19 Joersch <uhlman...@googlemail.com>

Joersch

unread,
Jan 20, 2012, 6:57:59 AM1/20/12
to androidannotations
i think it is not a problem with the thrown exception
NoClassDefFoundError. This problem is a little bit later. The javac
task is not generating the sources (underscore versions of the
classes)
Perhaps, it is a idea, generate the sources before execute the javac
ant task separatly?
Does everybody experience, how can i generate them stand alone?



On 20 Jan., 08:37, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> I'm not an Ant expert, I didn't see anything that looks like a problem.
> Maybe mat.boniface will have other ideas ?
>
> Meanwhile, I created an issue, and we are going to take care of that
> CodeModel bug:https://github.com/excilys/androidannotations/issues/71
>
> Hopefully it should solve your problem.
>
> 2012/1/19 Joersch <uhlmann.jo...@googlemail.com>
> ...
>
> Erfahren Sie mehr »

Joersch

unread,
Jan 20, 2012, 10:37:33 AM1/20/12
to androidannotations
Hello Pierre,
shuya-inc wrote in the issue https://github.com/excilys/androidannotations/issues/71
the android.jar issnt pressent int the classpath. i figure out
additionally this path into the build.xml into the javac ant task:
<classpath>
<fileset dir="${extensible.libs.classpath}" includes="*.jar" />
<fileset dir="${sdk.dir}/platforms/android-14"
includes="android.jar" />
<fileset dir="compile-libs" includes="*.jar"/>
</classpath>

And now the NoClassDefFoundError (see below) issnt thrown anymore. Hey
fine!

But a new Exception is now throw in the generate process:

[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.ExceptionInInitializerError
[javac] at java.lang.Class.forName0(Native Method)
[javac] at java.lang.Class.forName(Class.java:169)
[javac] at
[javac] Caused by: java.lang.RuntimeException: Stub!
[javac] at android.graphics.Rect.<init>(Rect.java:5)
[javac] at
greendroid.widget.PageIndicator.<clinit>(PageIndicator.java:69)
[javac] ... 63 more

you have an idea what is this problem?
joersch
> ...
>
> Erfahren Sie mehr »

Pierre-Yves Ricau

unread,
Jan 20, 2012, 12:10:31 PM1/20/12
to androidan...@googlegroups.com
This is a related problem. CodeModel tries to load the class with Class.forName, before falling back to using only the string name, but it only catches ClassNotFoundException. Previously, the class wasn't available, so you had NoClassDefFoundException.

Now, the class is loaded, and then it tries to load the PageIndicator class (from GreenDroid), which has some static initializer that create a new Rect. However, since the Android Jar is a stub jar, you get the "Stub!" exception :) . Which is quite normal...

We'll have to blame CodeModel on that, but we can fix that I think. I'll do it here: https://github.com/excilys/androidannotations/issues/71 .

Thanks for giving more info.

2012/1/20 Joersch <uhlman...@googlemail.com>

Joersch

unread,
Jan 23, 2012, 6:50:27 AM1/23/12
to androidannotations
i use GreedDroid. This is a external library project. Exclipse can
import such library project easilly. The compilation with ecllipe is
works fine, but not via ant.
Perhaps AA can't access to such external librarys in they code
generation process. I dont know, how can i do this.

Does everybody use AndroidAnnotaion and Greeddroid in the same
project?
thanks.



On 20 Jan., 18:10, Pierre-Yves Ricau <py.ri...@gmail.com> wrote:
> This is a related problem. CodeModel tries to load the class with
> Class.forName, before falling back to using only the string name, but it
> only catches ClassNotFoundException. Previously, the class wasn't
> available, so you had NoClassDefFoundException.
>
> Now, the class is loaded, and then it tries to load the PageIndicator class
> (from GreenDroid), which has some static initializer that create a new
> Rect. However, since the Android Jar is a stub jar, you get the "Stub!"
> exception :) . Which is quite normal...
>
> We'll have to blame CodeModel on that, but we can fix that I think. I'll do
> it here:https://github.com/excilys/androidannotations/issues/71.
>
> Thanks for giving more info.
>
> 2012/1/20 Joersch <uhlmann.jo...@googlemail.com>
>
>
>
>
>
>
>
> > Hello Pierre,
> > shuya-inc wrote in the issue
> >https://github.com/excilys/androidannotations/issues/71
> > the android.jar issnt pressent int the classpath. i figure out
> > additionally this path into the build.xml into the javac ant task:
> > <classpath>
> >     <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
> >     <fileset dir="${sdk.dir}/platforms/android-14"
> > includes="android.jar" />
> >     <fileset dir="compile-libs" includes="*.jar"/>
> > </classpath>
>
> > And now the NoClassDefFoundError (see below) issnt thrown anymore. Hey
> > fine!
>
> > But a new Exception is now throw in the generate process:
>
> >    [javac] An annotation processor threw an uncaught exception.
> >    [javac] Consult the following stack trace for details.
> >     [javac] java.lang.ExceptionInInitializerError
> >     [javac]     at java.lang.Class.forName0(Native Method)
> >    [javac]     at java.lang.Class.forName(Class.java:169)
> >    [javac]     at
>
> ...
>
> Erfahren Sie mehr »

Joersch

unread,
Jan 31, 2012, 7:42:40 AM1/31/12
to androidannotations
Hello Pierre,
another approach, perhaps it is a good idea the generation process
will be done only from eclipse, because the eclipse integration works
realy fine. And then only compile and build all them with ant. I
configure this, but i get some compile errors in ant compile task like
this:

[javac] ...\HelpActivity_.java:31: type parameters of <T>T cannot be
determined; no unique maximal instance exists for type variable T with
upper bounds int,java.lang.Object
[javac] helpId = cast_(extras_.get("helpId"));

Line 31 is:
helpId = cast_(extras_.get("helpId"));


The generated cast_ Method in the same class is:
@SuppressWarnings("unchecked")
private<T >T cast_(Object object) {
return ((T) object);
}

the @Extra Annotation in my HelpActivity Class is:
@Extra("helpId") protected int helpId;
@Extra("helpName") protected String helpName;

I am a little bit surprised. This Error is only thrown if the
parameter is numeric. The string parameter (in example helpName) isnt
thown this error.
Do you have an idea what is the reason?

joersch
> ...
>
> Erfahren Sie mehr »

Pierre-Yves Ricau

unread,
Feb 2, 2012, 4:59:30 AM2/2/12
to androidan...@googlegroups.com
Hello Joersch,

Regarding your initial problem (using Ant), we have fixed it, here : https://github.com/excilys/androidannotations/issues/71

If you use the latest 2.3 snapshot (or the soon to come 2.3 release), it should work. Please test and let us know if it doesn't work.

Latest 2.3 Snapshot : https://oss.sonatype.org/content/repositories/snapshots/com/googlecode/androidannotations/androidannotations/2.3-SNAPSHOT/androidannotations-2.3-20120130.151007-33.zip

Regarding your latest error : that's something different. You might have found another bug.

I have had this kind of problems with Generics in JEE projects in the past. Some compilers are more powerful then others when dealing with unsafe casts and generics.

Could you please tell us the output of the following command :
javac -version


2012/1/31 Joersch <uhlman...@googlemail.com>

Pierre-Yves Ricau

unread,
Feb 2, 2012, 5:19:59 AM2/2/12
to androidan...@googlegroups.com
I was able to reproduce the bug. I'll try to fix it for 2.3 release :) (you don't need to tell me your javac version, it's not that much related).

2012/2/2 Pierre-Yves Ricau <py.r...@gmail.com>

Pierre-Yves Ricau

unread,
Feb 2, 2012, 6:23:35 AM2/2/12
to androidan...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages