UdhayaBalaji / androidannotations

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

AfterViews causes cmd line build to fail. #153

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. android update project --path .
2. ant debug

What is the expected output? 
A successful ant build.

What do you see instead?
An error in the packaging:
java.lang.IllegalArgumentException: already added: 
Lcom/googlecode/androidannotations/annotations/AfterViews;

I thinks AfterViews has been included twice.

What version of AndroidAnnotations are you using? 
2.2

On what operating system?
Both Win7 and Ubuntu

I see this consistently across several projects that build fine in Eclipse, and 
build fine on the cmd line if we remove androidannotations.

This really makes it hard to use androidannotations with an automated build.

Original issue reported on code.google.com by johngray...@gmail.com on 28 Dec 2011 at 3:12

GoogleCodeExporter commented 8 years ago
This error is thrown by dx command when two classes with the same name and 
package name are detected.

Have you placed both the androidannotations-X.Y.jar and 
androidannotations-X.Y-api.jar in the "libs" folder of your project ? 

All the jars installed in the "libs" folder are directly passed to the dx 
command, and so, they are packaged in dex format in your apk file. This is not 
good because a lot of code that is not used at runtime is embedded in your apk .

The only (relatively acceptable) workaround I found is : 
- Remove androidannotations-X.Y.jar from the "libs" folder (let the 
androidannotations-X.Y-api.jar in this folder) and install it in another folder 
("compile-libs" for this example)
- Override the "-compile" target of the imported ant build file by copying it 
from the $ANDROID_SDK$/tools/ant/build.xml to your $PROJECT_ROOT$/build.xml
- add the content of "compile-libs" to the classpath when <javac> is invoked 
(in the "-compile" target of your $PROJECT_ROOT$/build.xml) : 
<javac ...>
    ...
    <classpath>
        <fileset dir="compile-libs" includes"*.jar"/>
        ...    
    </classpath>
</javac>

You're right, working with ant + android + androidannotations is not easy at 
the moment, we are working on the documentation for automated builds.

Original comment by mat.boni...@gmail.com on 28 Dec 2011 at 4:22

GoogleCodeExporter commented 8 years ago
https://github.com/excilys/androidannotations/issues/23

Original comment by py.ricau on 6 Jan 2012 at 3:54