Keep the class from squeezing

In my Android application, I have a DbHelper class that extends OrmLiteSqliteOpenHelper , which extends SQLiteOpenHelper . The launch of ProGuard on the project was completed successfully, but later in the run I get an error message: java.lang.NoClassDefFoundError: com.example.myapp.mypackage.DbHelper

I added -keep class com.example.myapp.mypackage.** { *; } -keep class com.example.myapp.mypackage.** { *; } in proguard-project.txt to exclude DbHelper compression, but this does not help.

I also tried adding the -dontshrink flag, just for the test, to disable the shrink operation, but that doesn't help either.

Any suggestions what I'm doing wrong and what to try? Thanks

UPD: Full stacktrace function

  E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.example.myapp.mypackage.DbHelper at com.example.myapp.App.onCreate(App.java:78) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391) at android.app.ActivityThread.access$1300(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) 

UPD 2: For OrmLite I use this configuration

 -keep class com.j256.** -keepclassmembers class com.j256.** { *; } -keep enum com.j256.** -keepclassmembers enum com.j256.** { *; } -keep interface com.j256.** -keepclassmembers interface com.j256.** { *; } 

UPD 3: I'm trying to execute undex classes.dex from proguarded apk using the dex2jar tool, and my DbHelper exists exactly where it should be

UPD 4: No, this is not a test application, this is a normal Android application.

UPD 5: Yes, DbHelper use some material from the support package, but in apkvali classes apk from the suppord package is omitted. In proguard-project.txt I have this configuration for the support package and Action Bar Sherlock

 -keep class android.support.v4.app.** { *; } -keep interface android.support.v4.app.** { *; } -keep class com.actionbarsherlock.** { *; } -keep interface com.actionbarsherlock.** { *; } 

How can I configure ProGuard correctly to keep the support package from being compressed?

+4
source share
1 answer

Thanks a lot @gunar for the help. I solved the problem, so I include the support package in proguard-project.txt as -libraryjars not as -injars . Therefore, the content was not packaged into the resulting apk, and dalvik cannot initialize DbHelper at run time, which uses classes from the support package

+1
source

Source: https://habr.com/ru/post/1488475/


All Articles