Re: Is it possible to exclude dependencies needed only at compile time from later phases with the new android gradle plugin?

401 views
Skip to first unread message

Xavier Ducrohet

unread,
May 29, 2013, 12:03:58 AM5/29/13
to adt...@googlegroups.com
We have prepared work for this but we don't totally support it. I don't think it'll be too complicated to add.


On Tue, May 28, 2013 at 7:58 AM, Juan Ramón González <jrgon...@gmail.com> wrote:
Hi,

i am working on a project that depends on the androidannotations framework. In order to the annotation processor to run i have to declare a dependency in this way:

dependencies {
    compile 'org.androidannotations:androidannotations:3.0-SNAPSHOT'
}

plus the needed repositories and the remaining android gradle plugin configuration.

With this dependency all the classes generated by the androidannotations annotation processor are created properly. But the problem comes when dx is run later on the build, when the following exception is produced:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/androidannotations/api/BackgroundExecutor;
        at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)

The thing is that the androidannotations processor already generates a BackgroundExecutor class on my source folders, but then gradle passes the jar for the compile dependency on androidannotations too thus leading to the duplication.

Is it possible to use the dependency on 'org.androidannotations:androidannotations:3.0-SNAPSHOT' only on the compile phase and exclude it afterwards?

I have tried to use things like:

configurations {
    apk.exclude module: 'org.androidannotations:androidannotations:3.0-SNAPSHOT'
}

based on the Gradle 1.6 user guide but it has no effect and the dependency is still always passed to dx leading to the duplication error.

Thanks,
Juan Ramon Gonzalez

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Juan Ramón González

unread,
May 29, 2013, 10:50:04 AM5/29/13
to adt...@googlegroups.com
So, is it planned to be supported soon? Or do you mean that it is possible for me to add it not complicatedly in the current 0.4.1 version of the android gradle plugin?

I wonder for instance from which configuration / variable does the libraries get passed to the dx binary. Maybe the configuration's exclusion i used could work but i am not using the proper configuration entry (apk)? Since the user guide of the android gradle plugin says that the dependencies follow the normal gradle DSL i think it may be possible to declare the exclusion in some way, but maybe i have not tried any right way to do so.

It will be helpful if the user guide included some explanation or diagram of what the default configuration / variants / flavours are and how things are inherited from one to the other and which variables / properties each of them has.

Thanks!

Xavier Ducrohet

unread,
May 29, 2013, 9:36:15 PM5/29/13
to adt...@googlegroups.com
What you're doing is technically right but doesn't do anything in our plugin. We need to add support for it.


Reply all
Reply to author
Forward
0 new messages