Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard Parse Exception Error. How to solve it

I am trying to export my application using Proguard 4.9 for the first time. But while exporting I am getting weird error in Console. Here it is -

[2013-06-11 14:59:42 - Project1] Proguard returned with error code 1. See console
[2013-06-11 14:59:42 - Project1] proguard.ParseException: Expecting type and name instead of just '***' before '(' in line 193 of file 'D:\Project Works\Android\Project1\bin\proguard.txt',
[2013-06-11 14:59:42 - Project1]   included from argument number 4
[2013-06-11 14:59:42 - Project1]    at proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:889)
[2013-06-11 14:59:42 - Project1]    at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:729)
[2013-06-11 14:59:42 - Project1]    at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:516)
[2013-06-11 14:59:42 - Project1]    at proguard.ConfigurationParser.parse(ConfigurationParser.java:165)
[2013-06-11 14:59:42 - Project1]    at proguard.ProGuard.main(ProGuard.java:476)

Here is the bin\proguard.txt file of line 192 & 193, where the error is coming

# onClick res/layout/tmenu.xml #generated:77
-keepclassmembers class * { *** (...); }

In project.properties I am using

target=android-7
proguard.config=proguard.cfg

And I am Android SDK and eclipse's plugins are updated to latest. Any idea how to fix it???

EDIT Here is the proguard.cfg in my project

-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 *;
}
like image 604
Jimit Patel Avatar asked Jun 11 '13 09:06

Jimit Patel


3 Answers

In my case I was receiving this error because of an empty onClick attribute in a layout file. So I removed onClick="", and the error was gone

like image 166
Jevgenij Evll Avatar answered Oct 19 '22 22:10

Jevgenij Evll


In my case the error was due to an empty onClick attribute on a button in a layout file. So I removed onClick="", and the error was gone.

TO find the the correct layout file that causing this error go to the corresponding file and find which layout file is causing this problem. The file is rightly on the or one line above the line indicated in the error message like

In line 193 of file 'D:\Project Works\Android\Project1\bin\proguard.txt' or  in line 114 of file 'C:..app\build\intermediates\proguard-rules\debug\aapt_rules.txt' .

Go through the layout file and find the onClick="" in any view. Remove it.
Hopefully this will work.

like image 44
Alvi Avatar answered Oct 19 '22 23:10

Alvi


Error is at

-keepclassmembers class * { *** (...); }

Replace with

-keepclassmembers class mypackage.** { *; }

And if you set this config for setters/ getters, you need to modify as

-keep class mybeans.** {
    void set*(***);
    void set*(int, ***);

    boolean is*(); 
    boolean is*(int);

    *** get*();
    *** get*(int);
}

Where : The '***' wildcard matches any type (primitive or non-primitive, array or non-array). The methods with the 'int' arguments matches properties that are lists.

like image 28
Pankaj Kumar Avatar answered Oct 20 '22 00:10

Pankaj Kumar