proguard.ParseException: Expecting class member name before '#' in Android Eclipse ADT - android

i try to optimize my Android Application code using Proguard with eclipse ADT v21.1.0-569685 on MAC.
i used project->Android Tools->export asigned Application package option for signing with my private certificate,on finish of signing i got following error,
project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library.reference.1=../google-play-services_lib
proguard-project.txt
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Console Log:
[2013-04-12 10:41:53 - MyApp] Proguard returned with error code 1. See console
[2013-04-12 10:41:53 - MyApp] proguard.ParseException: Expecting class member name before '#' in line 82 of file '/Users/MyOrg/Android_workspace/MyApp/bin/proguard.txt',
[2013-04-12 10:41:53 - MyApp] included from argument number 6
[2013-04-12 10:41:53 - MyApp] at proguard.ConfigurationParser.readNextWord(ConfigurationParser.java:1133)
[2013-04-12 10:41:53 - MyApp] at proguard.ConfigurationParser.readNextWord(ConfigurationParser.java:1117)
[2013-04-12 10:41:53 - MyApp] at proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:845)
[2013-04-12 10:41:53 - MyApp] at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:697)
[2013-04-12 10:41:53 - MyApp] at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:490)
[2013-04-12 10:41:53 - MyApp] at proguard.ConfigurationParser.parse(ConfigurationParser.java:139)
[2013-04-12 10:41:53 - MyApp] at proguard.ProGuard.main(ProGuard.java:484)
How to solve the above issue?
In prouard.project file I read
If your project uses WebView with JS, uncomment the following and
specify the fully qualified class name to the JavaScript interface
class:
I have used webview in two activity with WebAppInterface.java class.How to do above statement?

Referring resource name like "#string/on_click_handler_name", in android:onClick attribute of your layout file is ok. However, proguard cannot resolve these references.
Check http://android.okhelp.cz/proguard-parseexception-expecting-class-member-name-before/ for more details.
Find corresponding value of #string/tha_lf_et_todate_onclick in your string.xml and update :
android:onClick="#string/tha_lf_et_todate_onclick"
to
android:onClick="onClickXXX"
in your layout file.
For the second question,
uncomment that piece of code, and replace "fqcn.of.javascript.interface.for.webview"
with the class's fully qualified name.

Related

proguard returned with error code 1 android eclipse

while exporting signed application package in android application from eclipse, i am getting the error proguard returned with error code 1 :see console
here is my project.property file
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
android.library.reference.1=../google-play-services_lib
android.library.reference.2=../ratinglibrary
android.library.reference.3=../appcompat_v7
android.library.reference.4=../ViewpagerLibrary
please anyone suggest me. Thanks in advance...

code obfuscation in android with proguard

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, unComment this (available properties: sdk.dir, user.home):
proGuard.config=${sdk.dir}/tools/ProGuard/ProGuard-android.txt:proGuard-project.txt
# Project target.
target=android-18
this is my project.properties file
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proGuard/proGuard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, unComment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepClassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
this is my proguard-project.txt
I am enabling proguard like this when I try to build apk in release mode I am getting error code 1 in eclipse Juno. if I use same code in android studio I can able to build release apk . if I reverse engineer the apk which got from android studio I can read the entire code so how I can obfuscate the code
to work with proguard you need to just enable proguard using gradil script .
open gradil file and enable minifiable true and try to sign your application

Proguard Returned With Error Code 1 Without Any Specific Information

I have problem with proguard, I have tried with many possible solutions but still does not solve my problem.
The only information I get from console is
Proguard returned with error code 1. See console
nothing more, this is a really bad error message I ever met.
I have set
proguard.config=proguard-project.txt
and nothing in proguard-project.txt that I believe only a couple of comments.
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
After couples of hours finding the solution, I found the solution. I just moved the proguard.jar to another directory which there is no space in the path, then I edited the proguard.bat in /bin folder to that directory. Eventually, the proguard is running fine and give me the error log that I expected.
Sample script.
#ECHO OFF
REM Start-up script for ProGuard -- free class file shrinker, optimizer,
REM obfuscator, and preverifier for Java bytecode.
rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0
IF EXIST "%PROGUARD_HOME%" GOTO home
SET PROGUARD_HOME=..
:home
java -jar C:\bin\proguard.jar %*
You have commented text file, it should be like this :
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-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 <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
Build using following commands:
cd <you project directory>
#update project properties
android update project -t 3 -p .
#clean the code
ant clean
# build the application
ant release

Proguard Error: Unknown option '(' in argument number 12

I can't export my project with proguard, I get this error and out of solutions..
I don't know where is this argument number 12 ...
[2013-05-14 17:38:39 - LiveWallpaper] Proguard returned with error code 1. See console
[2013-05-14 17:38:39 - LiveWallpaper] Error: Unknown option '(' in argument number 12
my project.properties:
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=proguard.cfg
# Project target.
target=android-13
and my proguard.cfg is empty.
Thanks!
Ok so I found the solution using
Proguard ParseException with Default proguard.cfg on Android
My problem was the my workplace directory folder name was with a "(" character .. so I moved it to another directory without whitespaces or "(" and it solved it.

Getting error while generating the .apk file if proguard is ON

I am using proguard to obfuscate the code.
I am getting the following error in console
Proguard returned with error code 1. See console
Warning: org.apache.cordova.CameraLauncher: can't find referenced class org.apache.commons.codec.binary.Base64
Warning: org.apache.cordova.CameraLauncher: can't find referenced class org.apache.commons.codec.binary.Base64
Warning: org.apache.cordova.CordovaWebView: can't find referenced method 'WebView(android.content.Context,android.util.AttributeSet,int,boolean)' in class android.webkit.WebView
Warning: org.apache.cordova.CordovaWebViewClient: can't find referenced method 'android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebView,java.lang.String)' in class android.webkit.WebViewClient
Warning: org.apache.cordova.CordovaWebViewClient: can't find referenced class android.webkit.WebResourceResponse
Warning: org.apache.cordova.CordovaWebViewClient: can't find referenced class android.webkit.WebResourceResponse
Warning: org.apache.cordova.CordovaWebViewClient: can't find referenced class android.webkit.WebResourceResponse
Warning: org.apache.cordova.CordovaWebViewClient: can't find referenced class android.webkit.WebResourceResponse
Warning: org.apache.cordova.CordovaWebViewClient: can't find referenced class android.webkit.WebResourceResponse
Warning: org.apache.cordova.FileUtils: can't find referenced class org.apache.commons.codec.binary.Base64
Warning: org.apache.cordova.FileUtils: can't find referenced class org.apache.commons.codec.binary.Base64
Warning: there were 9 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
My project.properties file is here
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=~/Desktop/Android/android-sdk-macosx/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-10
My proguard-project.txt is here
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
How to solve this?
I fixed it by adding this in my proguard-project.txt
-keep public class * extends com.phonegap.api.Plugin
-keep public class org.apache.cordova.DroidGap
-keep public class org.apache.cordova.**
-libraryjars /Users/Nasir/Desktop/libs/commons-codec.jar
-dontwarn android.webkit.*
You can add the following to your proguard-project.txt. It worked for me on Cordova (PhoneGap) 2.1:
-keep public class * extends com.phonegap.api.Plugin
-keep public class * extends org.apache.cordova.api.Plugin
-keep public class org.apache.cordova.DroidGap
-keep public class org.apache.cordova.**
-libraryjars libs/commons-codec-1.7.jar
-dontwarn android.webkit.*
-dontwarn org.apache.**

Categories

Resources