Having an issue with Dagger Hilt Proguard Rules

Hello Everyone,
I’m a beginner Android developer facing a challenge with Proguard while using Dagger Hilt for dependency injection in my project. Despite trying various solutions, I’m still encountering errors related to missing classes generated by Dagger Hilt.

In essence, when attempting to build my app, I receive errors indicating missing classes from Dagger Hilt, even after implementing Proguard rules suggested in the Dagger repository. This issue has proven to be quite stubborn, and I’m seeking guidance from the community to resolve it.

Could someone experienced with Dagger Hilt and Proguard offer insights into properly configuring Proguard to address these errors? here is my code in my project:

// proguard-rules.pro

  # Keep file R and Manifest
    -keep class **.R
    -keep class **.R$* {*;}
    -keep class **.BuildConfig {*;}
    -keep class **.Manifest {*;}

    -keep class androidx.constraintlayout.motion.widget.KeyAttributes { *; }


    # Keep Dependency Injection Framework related classes and methods
    -keep class dagger.hilt.** { *; }
    -keep class javax.inject.** { *; }
    -keep class javax.annotation.** { *; }

    # Keep Model and Repository Classes
    -keep class com.example.core.data.model.** { *; }
    -keep class com.example.core.data.repo.** { *; }

    # Keep ViewModels
    -keep class * extends androidx.lifecycle.ViewModel

    # Keep Parcelable Classes
    -keep class * implements android.os.Parcelable {
        public static final android.os.Parcelable$Creator *;
    }

    # Keep UI-related classes
    -keep class com.example.ui.activity.** { *; }
    -keep class com.example.ui.fragment.** { *; }
    -keep class com.example.service.** { *; }

    # Menjaga semua kelas dalam paket tertentu
    -keep class com.example.package.** { *; }

    # Menjaga semua kelas yang disebutkan dalam file tertentu
    #-keep @com.example.rules.txt


    # Menjaga kelas model
    -keep class com.example.model.** { *; }

    # Menjaga kelas service
    -keep class com.example.service.** { *; }

    # Menjaga kelas-kelas yang diperlukan untuk penanganan SSL/TLS
    -keep class okhttp3.internal.platform.ConscryptPlatform {*;}
    -keep class okhttp3.internal.platform.OpenJSSEPlatform {*;}
    -keep class org.bouncycastle.** {*;}
    -keep class org.conscrypt.** {*;}
    -keep class org.openjsse.** {*;}


    # Keep classes required by OpenJSSE
    -keep class sun.security.x509.** { *; }
    -keep class sun.util.logging.** { *; }

    -keep class com.example.projectone.GithubUserApplication { *; }
    -keep class com.example.projectone.ui.main.MainActivity { *; }
    -keep class com.example.projectone.ui.userdetail.DetailUserActivity { *; }

# Keep classes generated by Hilt
    -keep class com.example.projectone.*Hilt* {
        *;
    }
# Keep Hilt generated classes
-keep class com.example.projectone.Hilt_* {*;}
-keep,allowobfuscation,allowshrinking @dagger.hilt.EntryPoint class *
-keep,allowobfuscation,allowshrinking @dagger.hilt.android.EarlyEntryPoint class *


// missing_rules.txt

-dontwarn com.example.projectone.Hilt_GithubUserApplication
-dontwarn com.example.projectone.ui.main.Hilt_MainActivity
-dontwarn com.example.projectone.ui.userdetail.Hilt_DetailUserActivity

here is the error

Missing class com.example.projectone.Hilt_GithubUserApplication (referenced from: void com.example.projectone.GithubUserApplication.() and 1 other context)

Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in missing_rules.txt (see the file above)

Missing class com.example.projectone.ui.main.Hilt_MainActivity (referenced from: void com.example.projectone.ui.main.MainActivity.() and 5 other contexts)

Missing class com.example.projectone.ui.userdetail.Hilt_DetailUserActivity (referenced from: void com.example.projectone.ui.userdetail.DetailUserActivity.() and 5 other contexts)

Caused by: [CIRCULAR REFERENCE: com.android.tools.r8.utils.b: Missing class com.example.projectone.Hilt_GithubUserApplication (referenced from: void com.example.projectone.GithubUserApplication.() and 1 other context)

Any assistance or advice would be greatly appreciated. Thank you for your time and your support.

Hello,

Thanks for reaching out! Unfortunately, this appears to be using R8 rather than ProGuard.

Best,
Jared