3

I am trying to use ProGuard with Android. I have found several ProGuard scrips to use, with the following one being an example (I have found several others that are the same or very similar). However, when I try and run ProGuard using this script, I get the error:

"Expecting java type before ';' in line 23 of file ..."

I am completely new to ProGuard. Can someone explain what is going wrong here

Thanks.

-injars bin(!.svn/**) -outjars obfuscated -libraryjars C:\android-sdk_r04-windows\android-sdk-windows\platforms\android-1.6\android.jar -libraryjars C:\GoogleAnalyticsAndroid_0.7\libGoogleAnalytics.jar -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -printmapping proguard.map -keepattributes SourceFile,LineNumberTable -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class com.android.vending.licensing.ILicensingService -keepclasseswithmembernames class * { native ; } -keepclasseswithmembernames class * { public (android.content.Context, android.util.AttributeSet); } -keepclasseswithmembernames class * { public (android.content.Context, android.util.AttributeSet, int); } -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } 
1
  • I'm not the down-voter, but I think the questions like 'where is my bug' is more suited for a forum, because others won't get much out of reading the solution to the bug. If the question is changed slightly to: how to make a proguard config-file that does what i want, it would be a much better question, because the answers would be useful to others. Commented Nov 3, 2010 at 13:32

3 Answers 3

3

The problem is here:

native ; 

Try changing it to:

native <methods>; 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response. I have actually already tried that and it fixes the error on that line, but then I get an error on the 'public (android.content.Context, android.util.AttributeSet);' line. The thing I don't understand is that, based on the posts that I have found, other people have clearly used this script successfully. Were they using an older version of ProGuard or something? Thanks.
Ok, I believe that I have identified the problem. These scripts were posted on some blogs, and it appears that the blogs 'ate' all the elements that were in angle brackets (e.g. the '<methods>' tag). Tracking down those elements and restoring them got it to work. Thanks
3

As I commented above, it appears that the problem stems from the fact that the blog from which I obtained the scripts seemed to be 'eating' anything with angle brackets. I decided it would be nice to post the corrected code, in case anyone else is looking for it. The corrected code is as follows:

-injars bin(!.svn/**) -outjars obfuscated -libraryjars C:\android-sdk\platforms\android-4\android.jar -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -printmapping proguard.map -keepattributes SourceFile,LineNumberTable -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class com.android.vending.licensing.ILicensingService -keepclasseswithmembernames class * { native <methods>; } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } 

Comments

0

From looking at the error message your compiler gave, it looks like the compiler is practically telling you what the problem is.

"Expecting java type before ';' in line 23 of file ..."

I lost count, but it looks like this line is line 23:

native ;

I don't know about you, but that doesn't look like valid Java at all.

1 Comment

It isn't java, it is a script that is input to ProGuard, which is a java program which takes java code and optimizes, and obfuscates it. I was hoping that someone with experience with ProGuard might know the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.