jberkel / android-plugin

An sbt plugin for Android development in Scala
https://groups.google.com/forum/#!forum/scala-on-android
Other
476 stars 113 forks source link

0.7 SNAPSHOT, ProGuard: include native method names by default #182

Closed stanch closed 11 years ago

stanch commented 11 years ago

Hi,

I suggest that

"-keepclasseswithmembers class * { native <methods>; }"

is added to the default ProGuard configuration so that native methods work. For motivation, see [1] and [2]. I am not sure if the renaming of this option, suggested in [2], is legit, but apparently it worked for me and solved java.lang.NoSuchMethodErrors. We can add both anyway.

[1] http://proguard.sourceforge.net/index.html#manual/examples.html, section 16 [2] http://stackoverflow.com/questions/8613098/obsolete-proguard-file-use-keepclasseswithmembers-instead-of-keepclasseswithm

Kind regards, Nick

stanch commented 11 years ago

P.S. If not in the default configuration, this line could be added to the cookbook that @fxthomas is preparing in his fork.

fxthomas commented 11 years ago

Good point, thanks! Are you actually using that in an app?

stanch commented 11 years ago

@fxthomas, yes, I am using it. Sometimes I wish for “ProGuard” recipes that would come with each dependency I use, like !sources or !javadoc, so there is no guessing and log digging involved. Actually I have a weird idea about this, will post in the group.

appamatto commented 11 years ago

Since this doesn't handle callbacks made from native code to Java/Scala methods, I usually find it necessary to -keep the entire Scala class that contains the native methods and callbacks anyway.

appamatto commented 11 years ago

It looks like this got resolved in the Google Group, so closing.