杰克逊和ProGuard

时间:2013-07-08 04:21:20

标签: android jackson obfuscation proguard

在我的Android应用中,我遇到了异常:

java.lang.IllegalStateException: Conflicting property name definitions: 
  'keywords' (for [field com.myapp.d.q#a]) vs 'download_urls' 
  (for [method com.myapp.d.q#a(1 params)])

但是当我对我的代码进行模糊处理时,我在调试模式下运行代码时不会遇到此异常。我在SO上阅读了几个回复,并对proguard.cfg文件做了很多编辑,这就是它的外观:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
-dontwarn android.text.*
-dontwarn org.apache.commons.*
-dontwarn org.scribe.services.*
-dontwarn com.fasterxml.jackson.databind.**

# Activities, services and broadcast receivers are specified in the manifest file so they won't be automatically included
-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
-keep public class com.crittercism.**

# Hold onto the mapping.text file, it can be used to unobfuscate stack traces in the developer console using the retrace tool
-printmapping mapping.txt

# Keep line numbers so they appear in the stack trace of the developer console
-keepattributes SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,Signature

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

# Custom view components might be accessed from your layout files
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

# event handlers can be specified in the layout files e.g. android:onClick="nextButton_onClick"
-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 *;
}

-keepclassmembers public class com.crittercism.* {
    *;
}

-keepnames class com.fasterxml.jackson.** { 
    *; 
}

但我无法解决这个问题。我在这里做错了什么?我正在使用杰克逊2.1.2罐子

2 个答案:

答案 0 :(得分:0)

修改proguard配置以包括“处理bean类”中提到的内容以及在POJO中指定jsonignoreproperties的组合确保我可以通过错误并创建一个带有混淆的APK。

答案 1 :(得分:0)

首先,异常信息是obfscate,使用Retrace工具和Proguard读取带有原始名称的消息。并再次发布异常消息。