Android - proguard.cfg error

2019-06-02 18:49发布

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

6条回答
我只想做你的唯一
2楼-- · 2019-06-02 19:23

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楼-- · 2019-06-02 19:23

selected the error in eclipse problems window. and it works for me.

查看更多
对你真心纯属浪费
4楼-- · 2019-06-02 19:24

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楼-- · 2019-06-02 19:28

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).

查看更多
SAY GOODBYE
6楼-- · 2019-06-02 19:30

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 *;
}
查看更多
Evening l夕情丶
7楼-- · 2019-06-02 19:33

if Previous answer didnt help

Then just create empty Android project in Eclipse and copy/replace created "proguard.cfg" file to your project.

查看更多
登录 后发表回答