Using ProGuard with Android.

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

"Waiting for Java type to"; line 23 of the file ... "

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

Thank.

-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);
}
+3
source share
3 answers

The problem is here:

native ;

Try changing it to:

native <methods>;
+3
source

, , , , , "" . , , - . :

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

From looking at the error message provided by your compiler, it seems that the compiler practically tells 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 do not know about you, but it does not look like valid Java at all.

0
source

Source: https://habr.com/ru/post/1771834/


All Articles