使用Proguard编码android代码时出错

使用Proguard编码android代码时出错,android,reverse-engineering,proguard,Android,Reverse Engineering,Proguard,我正在使用proguard保护我的android apk不受逆向工程的影响 但当我完成了在我的应用程序中安装proguard工具所需的所有步骤后,它会出现如下错误: [2014-03-11 10:55:04 - DemoProApp] Proguard returned with error code 1. See console [2014-03-11 10:55:04 - DemoProApp] proguard.ParseException: Expecting type and name

我正在使用proguard保护我的android apk不受逆向工程的影响

但当我完成了在我的应用程序中安装proguard工具所需的所有步骤后,它会出现如下错误:

[2014-03-11 10:55:04 - DemoProApp] Proguard returned with error code 1. See console
[2014-03-11 10:55:04 - DemoProApp] proguard.ParseException: Expecting type and name instead of just '***' before '(' in line 85 of file 'D:\Ranjana\New folder\DemoProApp\bin\proguard.txt',
[2014-03-11 10:55:04 - DemoProApp]   included from argument number 6
[2014-03-11 10:55:04 - DemoProApp]  at   `proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:857)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:697)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:490)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ConfigurationParser.parse(ConfigurationParser.java:139)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ProGuard.main(ProGuard.java:484)
[2014-03-11 10:55:04 - DemoProApp] '-jar' is not recognized as an internal or external command,
[2014-03-11 10:55:04 - DemoProApp] operable program or batch file.`
-keep class com.google.ads.** # Don't proguard AdMob classes
-dontwarn com.google.ads.** # Temporary workaround for v6.2.1. It gives a warning that    you can ignore
# Add any classes the interact with gson
-keep class com.example.Get_TargetTask
-keep class com.example.Get_Update_Task
-keep class com.example.GetAlertTask_CGM
-keep class com.example.GetAlertTask
-keep class com.example.GetApplicationDrawable
-keep class com.example.GetAssignedWorkTask
-keep class com.example.GetBarCode
-keep class com.example.GetRootTask
-keep class com.example.GetSignature

-keep class com.example.GetSmsTask
-keep class com.example.GuiNotificationActivity

-keep public class com.example.** {*;}
 ##---------------Begin: proguard configuration common for all Android apps ----------
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
 -dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
 -dump class_files.txt
 -printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
 -allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''
 -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
-dontnote com.android.vending.licensing.ILicensingService
# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.


-keepclassmembers class **.R$* {
public static <fields>;
}  
# Preserve the special static methods that are required in all enumeration classes.
1. keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keepclassmembers class com.example.** { *; }
-keep public class * {
 public protected *;
}
-keep class com.example.Assign_revert.java.** {
void set*(***);
void set*(int, ***);

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

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


-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
##---------------End: proguard configuration common for all Android apps ----------

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields.   Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

##---------------End: proguard configuration for Gson  ----------

2. List item
我的Proguard-project.txt文件如下:

[2014-03-11 10:55:04 - DemoProApp] Proguard returned with error code 1. See console
[2014-03-11 10:55:04 - DemoProApp] proguard.ParseException: Expecting type and name instead of just '***' before '(' in line 85 of file 'D:\Ranjana\New folder\DemoProApp\bin\proguard.txt',
[2014-03-11 10:55:04 - DemoProApp]   included from argument number 6
[2014-03-11 10:55:04 - DemoProApp]  at   `proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:857)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:697)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:490)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ConfigurationParser.parse(ConfigurationParser.java:139)
[2014-03-11 10:55:04 - DemoProApp]  at proguard.ProGuard.main(ProGuard.java:484)
[2014-03-11 10:55:04 - DemoProApp] '-jar' is not recognized as an internal or external command,
[2014-03-11 10:55:04 - DemoProApp] operable program or batch file.`
-keep class com.google.ads.** # Don't proguard AdMob classes
-dontwarn com.google.ads.** # Temporary workaround for v6.2.1. It gives a warning that    you can ignore
# Add any classes the interact with gson
-keep class com.example.Get_TargetTask
-keep class com.example.Get_Update_Task
-keep class com.example.GetAlertTask_CGM
-keep class com.example.GetAlertTask
-keep class com.example.GetApplicationDrawable
-keep class com.example.GetAssignedWorkTask
-keep class com.example.GetBarCode
-keep class com.example.GetRootTask
-keep class com.example.GetSignature

-keep class com.example.GetSmsTask
-keep class com.example.GuiNotificationActivity

-keep public class com.example.** {*;}
 ##---------------Begin: proguard configuration common for all Android apps ----------
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
 -dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
 -dump class_files.txt
 -printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
 -allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''
 -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
-dontnote com.android.vending.licensing.ILicensingService
# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.


-keepclassmembers class **.R$* {
public static <fields>;
}  
# Preserve the special static methods that are required in all enumeration classes.
1. keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keepclassmembers class com.example.** { *; }
-keep public class * {
 public protected *;
}
-keep class com.example.Assign_revert.java.** {
void set*(***);
void set*(int, ***);

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

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


-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
##---------------End: proguard configuration common for all Android apps ----------

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields.   Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

##---------------End: proguard configuration for Gson  ----------

2. List item
-保留com.google.ads类。*#不要对AdMob类进行保护
-dontwarn com.google.ads.*#v6.2.1的临时解决方案。它给出了一个你可以忽略的警告
#添加任何与gson交互的类
-保持类com.example.Get_TargetTask
-keep class com.example.Get_Update_任务
-保持类com.example.GetAlertTask\u CGM
-保持类com.example.GetAlertTask
-保持类com.example.GetApplicationDrawable
-保留类com.example.GetAssignedWorkTask
-保留类com.example.GetBarCode
-保持类com.example.GetRootTask
-保留类com.example.GetSignature
-保持类com.example.GetSmsTask
-保持类com.example.GuiNotificationActivity
-保持公共类com.example.*{*;}
##---------------Begin:proguard配置适用于所有Android应用程序----------
-优化过程5
-dontusemixedcaseclassnames
-DontskipnonPublicLibraryClass
-dontskipnonpubliclibraryclassmembers
-不要翻转
-冗长的
-dump class_files.txt
-printseeds.txt
-printusage unused.txt
-printmapping.txt
-优化!代码/简化/算术,!字段/*,!类/合并/*
-允许访问修改
-keepattributes*注释*
-重命名SourceFileAttribute源文件
-keepattributes源文件,LineNumberTable
-重新打包类“”
-keep public class*扩展android.app.Activity
-keep public class*扩展android.app.Application
-keep public class*扩展了android.app.Service
-keep public class*扩展了android.content.BroadcastReceiver
-keep public class*扩展了android.content.ContentProvider
-keep public class*扩展了android.app.backup.BackupAgentHelper
-keep public class*扩展了android.preference.preference
-保持公共类com.android.vending.licensing.ILicensingService
-dontnote com.android.vending.licensing.ILicensingService
#显式保留所有序列化成员。可序列化接口
#只是一个标记接口,因此无法保存它们。
-keepclassmembers类*实现java.io.Serializable{
静态最终长SerialVersionId;
私有静态final java.io.ObjectStreamField[]serialPersistentFields;
私有void writeObject(java.io.ObjectOutputStream);
私有void readObject(java.io.ObjectInputStream);
java.lang.Object WriterReplace();
java.lang.Object readResolve();
}
#保留所有本机方法名称及其类的名称。
-KeepClassSwithMemberNames类*{
本地人;
}
-KeepClassSwithMemberNames类*{
public(android.content.Context、android.util.AttributeSet);
}
-KeepClassSwithMemberNames类*{
public(android.content.Context,android.util.AttributeSet,int);
}
#保留可能被访问的R类的内部类的静态字段
#通过反省。
-keepclassmembers类**.R$*{
公共静态;
}  
#保留所有枚举类中所需的特殊静态方法。
1.keepclassmembers枚举*{
公共静态**[]值();
公共静态**valueOf(java.lang.String);
}
-keepclassmembers类com.example.*{*;}
-保持公开课*{
受公众保护*;
}
-保留com.example.Assign_revert.java类。**{
无效集*(***);
无效集*(整数,***);
布尔值是*();
布尔值为*(int);
***得到*();
***获取*(int);
}
-keep class*实现android.os.Parcelable{
公开静态最终android.os.Parcelable$Creator*;
}
##---------------结束:所有Android应用程序的通用proguard配置----------
##---------------开始:Gson的proguard配置----------
#Gson在处理字段时使用存储在类文件中的泛型类型信息。前卫
#默认情况下删除此类信息,因此将其配置为保留所有信息。
-保留署名
#用于使用GSON@Expose注释
-keepattributes*注释*
#Gson特定类
-保持类sun.misc.Unsafe{*;}
#-保持类com.google.gson.stream.*{*;}
#将通过Gson进行序列化/反序列化的应用程序类
-保持类com.google.gson.examples.android.model.*{*;}
##---------------结束:Gson的proguard配置----------
2.列表项

错误消息指的是文件
proguard.txt
的第85行(不是
proguard project.txt
)。该行在返回类型(通配符
***
)和方法参数的左括号之间似乎缺少方法名称


请注意,现在的Android SDK包含一个标准配置文件,该文件已经为您指定了所有通用的Android配置(使用-printseeds,-keepattributes等)。

progurad.txt是bin文件夹中自动生成的文件,我们无法修改proguard.txt中的任何内容。您是对的。这是生成该文件的Android SDK中aapt工具中的一个错误。它似乎在解释您的一个资源文件时遇到问题。您应该尝试找出它在proguard.txt中创建错误行的原因,并可能通过调整资源文件来解决它。这里有两个关于堆栈溢出的类似报告。