UdhayaBalaji / androidannotations

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

AndroidAnnotations JAR should not have same classes in API JAR #146

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When combining both the full JAR and the API JAR, I get an error saying that 
some classes have already been loaded.  This is because the full JAR is a 
superset of the API JAR, hence they can't be combined together.

While only the API JAR should be included in Android projects, setting up build 
systems such as Gradle is a bit more complicated as it is not possible to 
define both JARs as dependencies and as part of the classpath.  For Gradle, I 
had to resort to including the full JAR as part of the project, and referencing 
it in the configuration.

It would be easier really if the full JAR needed the API JAR to work 
completely, as all the API JAR-specific classes are not duplicated.  I'm not 
fully aware of the decisions with AndroidAnnotations early on, so this might be 
a moot point.

Original issue reported on code.google.com by eal...@gmail.com on 12 Dec 2011 at 2:16

GoogleCodeExporter commented 8 years ago
I think you have a good point here. My main concern is that many of our users 
don't use Maven in their Android projects, so it's not easy for them to deal 
with dependencies, and I'd rather not ask them to add multiple jar to their 
annotation processing classpath.

I'm starting to think that maybe we should have 3 main artifact instead of 2 :

androidannotations-full (contains core, api and code model) : for non maven 
users
androidannotations (contains core, depends on api and code model) : for maven 
users
androidannotations-api (no dependencies)  : runtime jar, for both maven and non 
maven users

What do you think ?

Original comment by py.ricau on 15 Dec 2011 at 4:59

GoogleCodeExporter commented 8 years ago
Yes I think that makes sense.  Should be much easier to add this at least for 
Gradle.

Original comment by eal...@gmail.com on 15 Dec 2011 at 8:50

GoogleCodeExporter commented 8 years ago
Funny enough, I'm starting to have the same error when using 
android-maven-plugin 3.0.0 (previously I used 3.0.0 -alpha-13).

[INFO] --- android-maven-plugin:3.0.0:dex (default-dex) @ functional-test-1-5 
---
[INFO] 
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java 
[-Xmx512m, -jar, 
/Users/pyricau/bin/android-sdk-mac_x86/platform-tools/lib/dx.jar, --dex, 
--output=/Users/pyricau/Projets/remote/androidannotations/AndroidAnnotations/fun
ctional-test-1-5/target/classes.dex, 
/Users/pyricau/.m2/repository/com/google/inject/guice/2.0-no_aop/guice-2.0-no_ao
p.jar, 
/Users/pyricau/.m2/repository/com/googlecode/androidannotations/androidannotatio
ns/2.3-SNAPSHOT/androidannotations-2.3-SNAPSHOT.jar, 
/Users/pyricau/.m2/repository/org/roboguice/roboguice/1.1.2/roboguice-1.1.2.jar,

/Users/pyricau/Projets/remote/androidannotations/AndroidAnnotations/functional-t
est-1-5/target/classes, 
/Users/pyricau/.m2/repository/com/sun/codemodel/codemodel/2.4.1/codemodel-2.4.1.
jar, 
/Users/pyricau/.m2/repository/com/googlecode/androidannotations/androidannotatio
ns/2.3-SNAPSHOT/androidannotations-2.3-SNAPSHOT-api.jar]
[INFO] 
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: 
Lcom/googlecode/androidannotations/annotations/AfterViews;
[INFO]  at 
com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[INFO]  at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[INFO]  at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[INFO]  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[INFO]  at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO]  at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[INFO]  at 
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245
)
[INFO]  at 
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO]  at 
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO]  at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[INFO]  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[INFO]  at com.android.dx.command.dexer.Main.run(Main.java:206)
[INFO]  at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO]  at com.android.dx.command.Main.main(Main.java:95)

Original comment by py.ricau on 30 Dec 2011 at 7:53

GoogleCodeExporter commented 8 years ago
However, I was able to fix that by using scope "provided" instead of "compile" 
for artifact androidannotations.

I should go read more about maven scopes...

Original comment by py.ricau on 30 Dec 2011 at 8:00

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

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