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

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

概述我将使用proguard混淆源代码.我的源代码定义了一些硬编码字符串,但我不知道如何防止proguard混淆我的String值(在下面的示例中为“tbl_people”)类publicclassMyDaoObject{publicstaticfinalStringTABLENAME="tbl_people";//otherdatabasecode}如果字符

我将使用proguard混淆源代码.

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

@H_404_9@public class MyDaoObject {  public static final String tablename = "tbl_people";   //other database code}

如果字符串混淆,sqlite将无法使用该字符串创建表.
有很多像这样的硬编码字符串.如何配置proguard来做到这一点?

任何建议都欢迎.

================================================== ==
更新:

这是logcat:

@H_404_9@07-13 17:55:12.310: E/AndroIDRuntime(11148): FATAL EXCEPTION: main07-13 17:55:12.310: E/AndroIDRuntime(11148): Process: com.myapp, PID: 1114807-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 DAOConfig07-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 DAOConfig07-13 17:55:12.310: E/AndroIDRuntime(11148):    at a.a.a.b.a.<init>(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.<init>(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 more07-13 17:55:12.310: E/AndroIDRuntime(11148): Caused by: java.lang.NoSuchFIEldException: tablename07-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

proguard的作者回答了类似的问题(但那家伙希望对字符串进行混淆):
https://stackoverflow.com/a/12665420/1643188

总结

以上是内存溢出为你收集整理的android-不要在proguard中混淆硬编码的字符串全部内容,希望文章能够帮你解决android-不要在proguard中混淆硬编码的字符串所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1078242.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存