问题
I imported an older project after a I installed the android SDK on a new computer. I am getting the following error in the "problems" window in eclipse.
Obsolete proguard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames proguard.cfg /MyApplication line 1
Here is the file. I tried replacing the -keepclasseswithmembernamesin this file with -keepclasseswithmembersbut it did not help.
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
回答1:
This is a sample config file that I use with proguard 4.4, JDK 1.6, target android 2.1.
Check your proguard version by double clicking on the jar file or with java -jar android-sdk/tools/proguard/lib/proguard.jar (use android sdk install path)
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-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 *;
}
回答2:
It seems to be an Eclipse / Android SDK error i suggest
1) close the project is giving error to you 2) remove it from eclipse ( do not remove folder or source ) 3) import the project you removed 4) clean and build again
Best regards stefano
回答3:
if Previous answer didnt help
Then just create empty Android project in Eclipse and copy/replace created "proguard.cfg" file to your project.
回答4:
This is what helped me; Right click on project's name, and click on "Android Project". Then select "Clear Lint Markers". Seems that I had accidentally run "Lint" for checking for some common problems after which I began seeing those proguard.cfg errors. Funny thing is that even though I was compiling in debug mode, eclipse would still complain about proguard (which is supposed to be used when compiling in release mode only).
回答5:
proguard.cfg will be in your project's root. edit it, replacing:
-keepclasseswithmembernames class * {
with
-keepclasseswithmembers class * {
worked for me running ADT bundle (v21.0.0-531062 with eclipse 3.7.2 using JDK1.7 under windowsxp).
回答6:
selected the error in eclipse problems window. and it works for me.
来源:https://stackoverflow.com/questions/8650595/android-proguard-cfg-error