adwiv / android-fat-aar

Gradle script that allows you to merge and embed dependencies in generted aar file
The Unlicense
1.46k stars 435 forks source link

Issues with warnings, interfaces and <T> class #37

Closed isometriq closed 8 years ago

isometriq commented 8 years ago

Beforehand, thanks for the update for gradle 2.2.0, it was now necessary since Android Studio does not ship with gradle plugin 1.5 !

I had some issues while using the latest commit of the fat-aar.gradle file. (commit 65cf9f785cd23f9179e2c57d93d60516d024943c)

I was able to resolve some of these issues by inserting the following lines:

keepattributes 'InnerClasses'
dontwarn '**'
keep 'class ** {*;}'
keep 'interface ** {*;}'

in the task generateXClass

Essentially seems to happen is that now the script is using proguard when packing things up. Since my sub-library was using org.apache httpclient, the collision warning were causing failure (along with others too).

This sub-library is also requiring "com.mcxiaoke.volley:library:1.0.19@aar" and I am able to "embed" it.

However I need to use the Reponse.Listener interface: http://afzaln.com/volley/com/android/volley/Response.Listener.html

With keep 'interface ** {*;}', it keeps the interface, but the gets stripped away.


My quick fix for now is to embed volley in my library instead of my sub-library, but I think this can be fixed with another proguard rule? When doing so all seems to work.

isometriq commented 8 years ago

Ok great, I was able to run by adding keepattributes 'Signature'

So in total, I have these:

keepattributes 'InnerClasses'
keepattributes 'Signature'
dontwarn '**'
keep 'class ** {*;}'
keep 'interface ** {*;}'

So now my question would be ..should that be added to the fat-aar.gradle script or is there something wrong in the way I use it? ..but I'm happy since it works now.

isometriq commented 8 years ago

Added more stuff:

keepattributes 'Exceptions'
keepattributes '*Annotation*'

to allow throws clauses in methods and specific annotations

adwiv commented 8 years ago

Does specifying just the keepattributes keep all the attributes instead of listing them individually? We anyway don't want to change anything other than the the resource classes.

I'll add this to the gradle file. Thanks.

adwiv commented 8 years ago

Thanks.. Added all keep attributes and classes in current commit. Not yet sure about dontwarn '**' as it will hide issues, will add later once we iron out issues.

isometriq commented 8 years ago

Yes, the super-wildcard sounds fishy for me too. I am not aware that the keepattributes directive alone will do something. Is that the case?

adwiv commented 8 years ago

From the proguard gradle manual : http://proguard.sourceforge.net/manual/gradle.html

keepattributes ['attribute_filter'] Preserve the specified optional Java bytecode attributes, with optional wildcards. If no name is given, all attributes are preserved.

It sounds like specifying just the keepattributes should work. Haven't tested it yet though.

isometriq commented 8 years ago

You are correct! ..tested here. Now it looks like this

keepattributes
dontwarn '**'
keep 'class ** {*;}'
keep 'interface ** {*;}'
adwiv commented 8 years ago

Great.. I have added everything except the dontwarn '**' to the standard script. Thanks a lot.

On 07-Oct-2016 8:23 PM, "Daniel Lorenzo" notifications@github.com wrote:

You are correct! ..tested here. Now it looks like this

keepattributes dontwarn '_' keep 'class {;}' keep 'interface _ {;}'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/adwiv/android-fat-aar/issues/37#issuecomment-252273729, or mute the thread https://github.com/notifications/unsubscribe-auth/AKfnZ4UC81_cSSm8vnxXnqT_hiXdItpfks5qxlzagaJpZM4KPIU4 .

adwiv commented 8 years ago

The latest release uses a different method of embedding R classes so proguard is no longer necessary. Thanks for the help.

Cheers.

isometriq commented 8 years ago

cool and thanks, I'll give it a look sometime soon

isometriq commented 8 years ago

Tried the latest commit and it works well for me, nice job!