【问题标题】:Error in Encoding android code using Proguard使用 Proguard 编码 android 代码时出错
【发布时间】:2014-04-14 14:01:42
【问题描述】:

我正在使用 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.`

我的 Proguard-project.txt 文件如下所示:

-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

【问题讨论】:

    标签: android reverse-engineering proguard


    【解决方案1】:

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

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

    【讨论】:

    • progurad.txt 是 bin 文件夹中自动生成的文件,我们无法修改 proguard.txt 中的任何内容。
    • 你是对的。这是生成文件的 Android SDK 中的 aapt 工具中的一个错误。解释您的资源文件之一似乎有问题。您应该尝试弄清楚为什么它会在 proguard.txt 中创建错误的行,并可能通过调整您的资源文件来解决它。 Stack Overflow 上有几个类似的报告。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-21
    • 1970-01-01
    • 2013-02-22
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    相关资源
    最近更新 更多