4

In my android app I have a DbHelper class which extends OrmLiteSqliteOpenHelper which extends SQLiteOpenHelper. Running ProGuard on project completes successfully, but later in run-time I'm getting an error: java.lang.NoClassDefFoundError: com.example.myapp.mypackage.DbHelper

I'm added -keep class com.example.myapp.mypackage.** { *; } into proguard-project.txt to exclude my DbHelper from shrinking but this doesn't helps.

Also I've tried to add -dontshrink flag, just for test, to disable shrinking step, but this doesn't helps too.

Any suggestions what I do wrong and what to try? Thanks

UPD: Full stacktrace

    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'm using this config

-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 tryed to undex classes.dex from proguarded apk with dex2jar tool and my DbHelper exists exactly where it should be

UPD 4: Nope, this isn't test application, this is usual android app

UPD 5: Yes, DbHelper use some kind of stuff from support package and in proguarded apk classes from suppord package is missed. In proguard-project.txt I have this config for 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 I can correctly configure ProGuard to preserve support package from shrinking?

Dmitriy Tarasov
  • 1,949
  • 20
  • 37
  • 2
    `com.example.myapp.mypackage.DbHelper` should be in the final APK. Can you post more from stacktrace? To be sure DBHelper is there, you can unpack the APK and undex the classes.dex file – gunar Jun 27 '13 at 11:17
  • Have you tried to `keep` your `DbHelper` and `OrmLiteSqliteOpenHelper` simultaneously? – yugidroid Jun 27 '13 at 11:23
  • 1
    strange ... can you unpack the final APK, undex it and compare the source structure with your expectation? – gunar Jun 27 '13 at 11:31
  • Is this a Android test application? – the-ginger-geek Jun 27 '13 at 11:39
  • 1
    Does DBHelper extend or use something from support package? Are the classes from support package exported in the final APK? I was getting these kind of issues when I was not exporting Android private libraries. – gunar Jun 27 '13 at 12:27

1 Answers1

1

Many thanks to @gunar for help. I solved the problem, the reason is that I include support package in proguard-project.txt as -libraryjars not as -injars. Therefore it's content wasn't packed into resulting apk and dalvik cannot initialize DbHelper at runtime which uses classes from support package

Dmitriy Tarasov
  • 1,949
  • 20
  • 37