New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find Application class when obfuscating with DexGuard #3174

Closed
grobarko opened this Issue Jul 12, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@grobarko

grobarko commented Jul 12, 2016

Goal

I'd like to be able to build a fully-working, release version of my application, obfuscated with DexGuard.

Expected Results

The app should be fully-working.

Actual Results

The app does not even start. I am getting this error on start:

FATAL EXCEPTION: main
Process: com.myapp.example, PID: 23560
java.lang.RuntimeException: Unable to instantiate application o.eE: java.lang.ClassNotFoundException: Didn't find class "o.eE" on path: DexPathList[[zip file "/data/app/com.myapp.example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.example-2/lib/x86, /data/app/com.myapp.example-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "o.eE" on path: DexPathList[[zip file "/data/app/com.myapp.example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.example-2/lib/x86, /data/app/com.myapp.example-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newApplication(Instrumentation.java:981)
at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680) 
at android.app.ActivityThread.-wrap1(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: o.eE
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
(I changed the package name for showing purpose only)

Also, during the build, I get these warnings from DexGuard

Warning: class [folders/1/1/realm/uk/co/chrisjenx/calligraphy/R$style.class] unexpectedly contains class [uk.co.chrisjenx.calligraphy.R$style]
Warning: class [folders/1/1/realm/uk/co/chrisjenx/calligraphy/R$styleable.class] unexpectedly contains class [uk.co.chrisjenx.calligraphy.R$styleable]
Warning: class [folders/1/1/realm/uk/co/chrisjenx/calligraphy/R.class] unexpectedly contains class [uk.co.chrisjenx.calligraphy.R]
(to be more precise, 738 of these, for all classes)

As a side note, these rules for Realm are included:
`-dontnote io.realm.RealmObject
-keep class * extends io.realm.RealmObject {
void set_(*);
_* get();
}

-keep class **RealmProxy extends io.realm.RealmObject {
public static ;
}

-dontnote io.realm.ValidationList
-keepclassmembers class io.realm.ValidationList {
public static java.util.List getProxyClasses();
}

-dontnote io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *

-dontnote io.realm.exceptions.*
-dontnote io.realm.internal.*
-keep class io.realm.exceptions.RealmError { *; }
-keep class io.realm.exceptions.RealmIOException { *; }
-keep class io.realm.internal.OutOfMemoryError { *; }
-keep class io.realm.internal.ColumnType { *; }
-keep class io.realm.internal.Mixed { *; }
-keep class io.realm.internal.Row { *; }
-keep class io.realm.internal.TableSpec { *; }`

Actions I tried

When I remove the apply plugin: 'realm-android' from my build.gradle (and with that I remove all usages for Realm in order to make a successful build), my app, obfuscated and optimized by DexGuard is fully-working.

I have checked all the DexGuard related issues (all of them are closed), such as this one:
#3022
...but, my problem still exists.

Version of Realm and tooling

Realm version(s): I tried all versions from 0.90.0 to 1.1.0

Android Studio version: 2.1.2

Android version and device: Android 6.0, Nexus S Emulator

I'd appreciate all help.
Tnx in advance

@zaki50

This comment has been minimized.

Show comment
Hide comment
@zaki50

zaki50 Jul 13, 2016

Contributor

Hi @grobarko

Are you using the latest version of DexGuard?
I saw an issue before that the old version of the DexGuard is not compatible with Realm.

Contributor

zaki50 commented Jul 13, 2016

Hi @grobarko

Are you using the latest version of DexGuard?
I saw an issue before that the old version of the DexGuard is not compatible with Realm.

@grobarko

This comment has been minimized.

Show comment
Hide comment
@grobarko

grobarko Jul 13, 2016

Hi @zaki50

I wasn't ineed using the latest version of DexGuard. I updated it and now it works.
Tnx for your reply and sorry I didn't thought of this before opening the issue.

grobarko commented Jul 13, 2016

Hi @zaki50

I wasn't ineed using the latest version of DexGuard. I updated it and now it works.
Tnx for your reply and sorry I didn't thought of this before opening the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment