Skip to content

[Dagger-Hilt] Error when applying obfuscation other than Proguard (Allatori) #4266

Open

Description

My project does not apply Proguard obfuscation, but uses the paid obfuscation library 'allatori'.
https://allatori.com/

When obfuscation is applied using the 'allatori' library, a crash error occurs saying that the Application Class cannot be found as shown below.

E FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 29344
java.lang.RuntimeException: Unable to instantiate application com.example.myapplication.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.example.myapplication.MyApplication" on path: DexPathList[[dex file "/data/ data/com.example.myapplication/code_cache/.overlay/base.apk/classes3.dex", zip file "/data/app/~~mQrlQmr7Qn7zEWzSzORolw==/com.example.myapplication-0AZUonxkcl235IRbMJg4Gg==/base.apk" ],nativeLibraryDirectories=[/data/app/~~mQrlQmr7Qn7zEWzSzORolw==/com.example.myapplication-0AZUonxkcl235IRbMJg4Gg==/lib/arm64, /system/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1332)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7532)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.myapplication.MyApplication" on path: DexPathList[[dex file "/data/data/com.example.myapplication/code_cache/.overlay/base. apk/classes3.dex", zip file "/data/app/~~mQrlQmr7Qn7zEWzSzORolw==/com.example.myapplication-0AZUonxkcl235IRbMJg4Gg==/base.apk"],nativeLibraryDirectories=[/data/app/~~mQrlQmr7Qn7zEWzSzORolw== /com.example.myapplication-0AZUonxkcl235IRbMJg4Gg==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
at android.app.Instrumentation.newApplication(Instrumentation.java:1158)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1324)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7532)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/myapplication/Hilt_MyApplication;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
...14 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.myapplication.Hilt_MyApplication" on path: DexPathList[[dex file "/data/data/com.example.myapplication/code_cache/.overlay/base. apk/classes3.dex", zip file "/data/app/~~mQrlQmr7Qn7zEWzSzORolw==/com.example.myapplication-0AZUonxkcl235IRbMJg4Gg==/base.apk"],nativeLibraryDirectories=[/data/app/~~mQrlQmr7Qn7zEWzSzORolw== /com.example.myapplication-0AZUonxkcl235IRbMJg4Gg==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
...17 more
[CIRCULAR REFERENCE:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/myapplication/Hilt_MyApplication;]
  1. When applying obfuscation other than Proguard, Could you share the configuration that need to be set or keep the auto generated classes from the obfuscation?

  2. My Project Dagger-Hilt Dependencies .
    implementation("com.google.dagger:hilt-android:2.48")
    kapt("com.google.dagger:hilt-android-compiler:2.48")

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions