8

I am one step away from making the method described here: Targeting Android with Scala 2.8 Trunk builds

work with a single project (vs one project for scala and one for android).

I've come across a problem. Using this input file (arguments to) proguard:

-injars bin;lib/scala-library.jar(!META-INF/MANIFEST.MF,!library.properties)

-outjar lib/scandroid.jar

-libraryjars lib/android.jar

-dontwarn
-dontoptimize
-dontobfuscate
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-keep public class org.scala.jeb.** { public protected *; }
-keep public class org.xml.sax.EntityResolver { public protected *; }

Proguard successfully builds scandroid.jar, however it appears to have included the generated R classes that the android resource builder generates and compiles. In this case, they are located in bin/org/jeb/R*.class. This is not what I want. The android dalvik converter cannot build because it thinks there is a duplicate of the R class (it's in scandroid and also the R*.class files). How can I modify the above proguard arguments to exclude the R*.class files from the scandroid.jar so the dalvik converter is happy? Edit: I should note that I tried adding ;bin/org/jeb/R.class;etc... to the -libraryjars argument, and that only seemed to cause it to complain about duplicate classes, and in addition proguard decided to exclude my scala class files too.

Community
  • 1
  • 1
Jeremy Bell
  • 5,253
  • 5
  • 41
  • 63
  • 1
    I don't know off the top of my head for proguard - you might try asking on the proguard forums at http://sourceforge.net/projects/proguard/forums/forum/182456 . You might be able to solve this another way. Is there a way to have Eclipse put the *.class files generated by the R stuff into a different directory (something other than bin)? – James Moore May 21 '10 at 23:43
  • I had a simiar question, got it answered [here](http://stackoverflow.com/questions/11325087/what-are-the-semantics-of-proguardinjars-in-sbt-android-plugin). – ioreskovic Jul 13 '12 at 09:07

2 Answers2

7

I use this option. You can find reference from link below and find "A complete Android application". http://proguard.sourceforge.net/index.html#/manual/examples.html

-keepclassmembers class **.R$* {
    public static <fields>;
}
alex2k8
  • 42,496
  • 57
  • 170
  • 221
theWook
  • 843
  • 9
  • 22
4

file filter !**/*R.java in other words this lien forces Proguard to keep all java files except R.java files in the obfuscation

Fred Grott
  • 3,505
  • 1
  • 23
  • 18