Is it possible to exclude a dependency jar from .aar package?

1,596 views
Skip to first unread message

Jia Pu

unread,
Feb 5, 2015, 1:22:23 PM2/5/15
to adt...@googlegroups.com
Hello,

I have a project in which the application depending on an android library module. Both the app and library modules depend on another jar, say foo.jar. foo.jar is installed on to device already. When I compile the library module, foo.jar will get included in the "libs" directory of the .aar package. This additional copy of foo.jar would cause runtime error -- "java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation".

So Is it possible to exclude a dependency jar from .aar package?

Thanks

Jia

Xavier Ducrohet

unread,
Feb 5, 2015, 8:33:20 PM2/5/15
to adt...@googlegroups.com
You can use provided instead of compile to only use it for compilation.

It's not working great in 1.0, but we've fixed its support in 1.1 (coming soon, rc1 already out).

--
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/d/optout.



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

Please do not send me questions directly. Thanks!

Jia Pu

unread,
Feb 6, 2015, 11:08:43 AM2/6/15
to adt...@googlegroups.com
Xavier, as you mentioned, in 1.0, "provided" does seem being honored. I will git 1.1 a shot.

Jia Pu

unread,
Feb 6, 2015, 11:45:56 AM2/6/15
to adt...@googlegroups.com
Since I can't switch to 1.1 rc1 immediately. Is it possible to add a task before or after assemble task to remove the included jar file?


On Thursday, February 5, 2015 at 5:33:20 PM UTC-8, Xavier Ducrohet wrote:

Xavier Ducrohet

unread,
Feb 6, 2015, 12:54:27 PM2/6/15
to adt...@googlegroups.com
Well you could always look at the final task that zip up the aar, hook a doFirst {} action and remove what you don't want.

This is very ugly (you can't really handle proper incremental mode this way), and it'll break task parallelization when it comes to Gradle, so I'd recommend moving to 1.1 ASAP and doing it correctly.
Reply all
Reply to author
Forward
0 new messages