I've been struggling with this one for a while now. I'm trying to Generate Signed APK in IntelliJ IDEA 13.1.3 and Run ProGuard 4.7 on the APK but I can't get rid of the following error:
Error: ProGuard: [project_name] Error: Can't read [C:\Program Files (x86)\Android\android-sdk\tools\proguard\libs] (No such file or directory)
The error message is preceded by this message:
Information: ProGuard: [project_name] Reading library directory [C:\Program Files (x86)\Android\android-sdk\tools\proguard\libs]
There is only a lib directory in that location containing proguard.jar and the two other jar files. I created an empty libs directory but got even more errors after that.
Otherwise the obfuscation seems to work properly, and without the obfuscation the signed APK is generated correctly.
The Android SDK Build-tools version is 20.
This is the proguard-project file:
-libraryjars libs
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class * extends java.util.ListResourceBundle
{
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable
{
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class *
{
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable
{
public static final ** CREATOR;
}
UPDATE
It seems that this problem boils down to the line -libraryjars libs in the proguard-project file. I managed to properly Generate Signed APK with a simple test project when I removed that line from proguard-project.txt. However, when -libraryjars libs wasn't removed, the obfuscation failed.
If that line is stripped when trying to run ProGuard on the actual project, it gives even more errors.
Thanks for your answer, Eric.
Actually, I already solved the problem. Just hadn't updated the answer here until now.
Yes, -libraryjars in proguard-project.txt was the root of all evil. I just included it there because of some example configurations I came across.
Here's the properly working configuration:
-keep class * extends java.util.ListResourceBundle
{
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable
{
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class *
{
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable
{
public static final ** CREATOR;
}
-keep public class com.google.android.gms.ads.**
{
public *;
}
-keep public class com.google.ads.**
{
public *;
}
-keep class com.android.vending.billing.**
-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-dontwarn com.google.android.gms.**
You should have -libraryjars or -injars in your configuration. The Android build process (Ant, Eclipse, Gradle, and presumably IntelliJ IDEA as well) internally already specifies those options for you.
I haven't come across the Android SDK adding -libraryjars to proguard-project.txt (and specified paths are relative to the directory of the configuration file itself, not to .../tools/proguard), but maybe you should update to the latest version of the SDK to avoid the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With