android 混淆字符串,android-不要在proguard中混淆硬编码的字符串

我将使用proguard混淆源代码.

我的源代码定义了一些硬编码字符串,但我不知道如何防止proguard混淆我的String值(在下面的示例中为“ tbl_people”)

public class MyDaoObject {

public static final String TABLENAME = "tbl_people";

//other database code

}

如果字符串混淆,SQLite将无法使用该字符串创建表.

有很多像这样的硬编码字符串.如何配置proguard来做到这一点?

任何建议都欢迎.

================================================== ==

更新:

这是logcat:

07-13 17:55:12.310: E/AndroidRuntime(11148): FATAL EXCEPTION: main

07-13 17:55:12.310: E/AndroidRuntime(11148): Process: com.myapp, PID: 11148

07-13 17:55:12.310: E/AndroidRuntime(11148): java.lang.RuntimeException: Unable to create application com.myapp.AudioPhotoApplication: a.a.a.d: Could not init DAOConfig

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4470)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.app.ActivityThread.access$1500(ActivityThread.java:144)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.os.Handler.dispatchMessage(Handler.java:102)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.os.Looper.loop(Looper.java:136)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.app.ActivityThread.main(ActivityThread.java:5140)

07-13 17:55:12.310: E/AndroidRuntime(11148): at java.lang.reflect.Method.invokeNative(Native Method)

07-13 17:55:12.310: E/AndroidRuntime(11148): at java.lang.reflect.Method.invoke(Method.java:515)

07-13 17:55:12.310: E/AndroidRuntime(11148): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)

07-13 17:55:12.310: E/AndroidRuntime(11148): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)

07-13 17:55:12.310: E/AndroidRuntime(11148): at dalvik.system.NativeStart.main(Native Method)

07-13 17:55:12.310: E/AndroidRuntime(11148): Caused by: a.a.a.d: Could not init DAOConfig

07-13 17:55:12.310: E/AndroidRuntime(11148): at a.a.a.b.a.(Unknown Source)

07-13 17:55:12.310: E/AndroidRuntime(11148): at a.a.a.b.a(Unknown Source)

07-13 17:55:12.310: E/AndroidRuntime(11148): at com.myapp.database.a.(Unknown Source)

07-13 17:55:12.310: E/AndroidRuntime(11148): at com.myapp.AudioPhotoApplication.onCreate(Unknown Source)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)

07-13 17:55:12.310: E/AndroidRuntime(11148): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4467)

07-13 17:55:12.310: E/AndroidRuntime(11148): ... 10 more

07-13 17:55:12.310: E/AndroidRuntime(11148): Caused by: java.lang.NoSuchFieldException: TABLENAME

07-13 17:55:12.310: E/AndroidRuntime(11148): at java.lang.Class.getField(Class.java:724)

07-13 17:55:12.310: E/AndroidRuntime(11148): ... 16 more

我认为问题来自字符串,因为当我保留处理数据库的类时,我的应用程序不再崩溃!

================================================== ==

更新2:

问题不是来自字符串值,而是字符串名称.这是我的问题:

https://groups.google.com/forum/#!msg/greendao/tyqjrx2otVo/PHExbn4iZk8J

解决方法:

您确定这是问题所在,因为ProGuard不会混淆其常见问题解答中所述的字符串:

No. String encryption in program code has to be perfectly reversible by definition, so it only improves the obfuscation level. It increases the footprint of the code. However, by popular demand, ProGuard’s closed-source sibling for Android, DexGuard, does provide string encryption, along with more protection techniques against static and dynamic analysis

标签:greendao,proguard,string,android

来源: https://codeday.me/bug/20191121/2052294.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值