John Gaby
John Gaby

Reputation: 1512

Using ProGuard with Android.

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);
}

Upvotes: 3

Views: 4144

Answers (3)

John Gaby
John Gaby

Reputation: 1512

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);
}

Upvotes: 3

finnw
finnw

Reputation: 48619

The problem is here:

native ;

Try changing it to:

native <methods>;

Upvotes: 3

Jason Whitehorn
Jason Whitehorn

Reputation: 13685

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.

Upvotes: 0

Related Questions