Don't obfuscate hardcoded string in proguard

android, greendao, proguard, string

Solution

Are you sure that this is the problem, because ProGuard doesn´t obfuscate string like stated in their FAQ:

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

Similiar question (but the guy wants strings to be obfuscated), author of proguard replied: https://stackoverflow.com/a/12665420/1643188

Problem

I'm going to obfuscate my source using proguard. My source defined some hardcode string and I don't know how to make prevent proguard to obfuscate my String value (It's "tbl_people" in below example) class ``` public class MyDaoObject { public static final String TABLENAME = "tbl_people"; //other database code } ``` If string obfuscated, The SQLite can't create table using that string. There are many hardcoded string like that. How can I config proguard to do that ? Any suggestion is welcome. ==================================================== Update: This is 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.<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 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 ``` I think the problem come from String because when I keep class that handle database, my app doesn't crash anymore !! ==================================================== Update 2: Problem didn't come from string value but string name. Here is my problem: https://groups.google.com/forum/#!msg/greendao/tyqjrx2otVo/PHExbn4iZk8J

Original source

Related problems