简体   繁体   中英

Proguard in Android Library

I am having an error with the Proguard file in Android.

The point is, I know how to use it in an Android Project, but now, I need to use it for an Android Library Project, and the .jar extracted (there is no resources on the library), to obfuscate the code, because I would like to distribute my library for everyone to use it, but with the code obfuscated.

My Android library project is a normal one, I just take the .jar with is contained in the "bin" folder from the Library Project, and I am trying to use the Proguard to obfuscate it this way:

java -jar proguard.jar @proguard-project -verbose

My Proguard file is the next one:

-injars in.jar -outjars out.jar

-libraryjars /home/jorider/wul4/adt-android/sdk/platforms/android-17/android.jar -libraryjars /home/jorider/wul4/adt-android/sdk/extras/android/support/v4/android-support-v4.jar -libraryjars commons-codec-repackaged-3.1-b36.jar -libraryjars httpmime-4.2.5.jar

-dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -verbose

-dontoptimize -dontpreverify

-keepattributes Annotation -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * { native ; }

-keepclassmembers public class * extends android.view.View { void set*( *); get (); }

-keepclassmembers class * extends android.app.Activity { public void *(android.view.View); }

-keepclassmembers enum * { public static * [] values(); public static * valueOf(java.lang.String); }

-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }

-keepclassmembers class * .R$ { public static ; }

-dontwarn android.support.**

The result I get for running that on the console is :

Shrinking...
java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?

Anyone knows why?

Thanks a lot!

You can find a configuration for processing libraries in the ProGuard manual > Examples > A typical library .

Notably, you'll need to preserve all public API:

-keep public class * {
    public protected *;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM