Error while generating release build or running gradle task gradle :app:minifyReleaseWithR8

I’m encountering an issue while trying to generate a release build or run the gradle :app:minifyReleaseWithR8 task for my Android application.
My Android project has two modules: app and core

The build process fails with an error message that looks something like this:

Missing class com.atech.core.module.FirebaseModule_ProvideFirebaseFactory (referenced from: java.lang.Object com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get())
Missing class com.atech.core.module.FirebaseModule_ProviderFirebaseAuthFactory (referenced from: java.lang.Object com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get())
Missing class com.atech.core.module.RoomModule_ProvideDatabaseFactory (referenced from: java.lang.Object com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get())
Missing class com.atech.core.module.RoomModule_ProvideResearchHubDaoFactory (referenced from: java.lang.Object com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get())
Missing class com.atech.core.room.ResearchHubDao (referenced from: java.lang.Object com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get() and 6 other contexts)
Missing class com.atech.core.room.model.ResearchMapper (referenced from: com.atech.core.use_cases.GetAllUserCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.getAllUserCase() and 2 other contexts)
Missing class com.atech.core.use_cases.AuthUseCases (referenced from: com.atech.core.use_cases.AuthUseCases com.atech.research.ui.screens.login.LoginViewModel.authUseCases and 8 other contexts)
Missing class com.atech.core.use_cases.DeleteAllUseCases (referenced from: com.atech.core.use_cases.DeleteAllUseCases com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.deleteAllUseCases() and 1 other context)
Missing class com.atech.core.use_cases.DeleteUserByIdUseCase (referenced from: com.atech.core.use_cases.DeleteUserByIdUseCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.deleteUserByIdUseCase() and 2 other contexts)
Missing class com.atech.core.use_cases.FireStoreUseCases (referenced from: java.lang.Object com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl$SwitchingProvider.get() and 3 other contexts)
Missing class com.atech.core.use_cases.GetAllResearchUseCase (referenced from: com.atech.core.use_cases.FireStoreUseCases com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.fireStoreUseCases() and 2 other contexts)
Missing class com.atech.core.use_cases.GetAllUserCase (referenced from: com.atech.core.use_cases.GetAllUserCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.getAllUserCase() and 2 other contexts)
Missing class com.atech.core.use_cases.GetUserByIdUseCase (referenced from: com.atech.core.use_cases.GetUserByIdUseCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.getUserByIdUseCase() and 2 other contexts)
Missing class com.atech.core.use_cases.GetUserDetailsUseFromAuthCase (referenced from: com.atech.core.use_cases.AuthUseCases com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.authUseCases() and 2 other contexts)
Missing class com.atech.core.use_cases.HasUserUseCase (referenced from: com.atech.core.use_cases.HasUserUseCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.hasUserUseCase() and 2 other contexts)
Missing class com.atech.core.use_cases.InsertUserUseCase (referenced from: com.atech.core.use_cases.InsertUserUseCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.insertUserUseCase() and 2 other contexts)
Missing class com.atech.core.use_cases.IsResearchExistUseCase (referenced from: com.atech.core.use_cases.IsResearchExistUseCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.isResearchExistUseCase() and 2 other contexts)
Missing class com.atech.core.use_cases.IsUserLoggedInUseCase (referenced from: com.atech.core.use_cases.AuthUseCases com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.authUseCases() and 3 other contexts)
Missing class com.atech.core.use_cases.LogInUseCase (referenced from: com.atech.core.use_cases.LogInUseCase com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.logInUseCase() and 1 other context)
Missing class com.atech.core.use_cases.LogInWithGoogle (referenced from: com.atech.core.use_cases.AuthUseCases com.atech.research.DaggerResearchHub_HiltComponents_SingletonC$ViewModelCImpl.authUseCases() and 2 other contexts)
Missing class com.atech.core.use_cases.WishListUseCases (referenced from: com.atech.core.use_cases.WishListUseCases com.atech.research.ui.screens.student.ui.research.main.ResearchViewModel.wishListUseCases and 10 other contexts)
Missing class com.atech.core.utils.JsonKt (referenced from: void com.atech.research.ui.screens.student.ui.research.detail.compose.ComposableSingletons$ResearchDetailsScreenKt$lambda-2$1.invoke(androidx.compose.runtime.Composer, int))
Missing class com.atech.core.utils.State$Error (referenced from: void com.atech.research.ui.screens.login.LoginViewModel$logIn$1$1.invoke(com.atech.core.utils.State))
Missing class com.atech.core.utils.State$Loading (referenced from: void com.atech.research.ui.screens.login.LoginViewModel$logIn$1$1.invoke(com.atech.core.utils.State))
Missing class com.atech.core.utils.State$Success (referenced from: void com.atech.research.ui.screens.login.LoginViewModel$logIn$1$1.invoke(com.atech.core.utils.State))
Missing class com.atech.core.utils.State (referenced from: void com.atech.research.ui.screens.login.LoginViewModel$logIn$1$1.invoke(com.atech.core.utils.State) and 1 other context)

I have tried the following steps to resolve the problem:

  • Clean and rebuild the project
  • Invalidate caches and restart Android Studio
  • Update Gradle and Android Gradle Plugin to the latest versions
  • Check for any potential conflicts or incompatibilities with third-party libraries
  • Ensure that all required dependencies are correctly declared in the project

However, none of these steps have resolved the issue so far.

Here is my (App module) build.gradle.kts file

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin.android)
    alias(libs.plugins.googleAndroidLibrariesMapsplatformSecretsGradlePlugin)
    id("com.google.dagger.hilt.android")
    id("com.google.devtools.ksp")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
}

android {
    namespace = "com.atech.research"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.atech.research"
        minSdk = 24
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
        multiDexEnabled = true
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        compose = true
        buildConfig = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.14"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
            excludes += "META-INF/gradle/incremental.annotation.processors"
        }
    }

}

dependencies {

    implementation(project(":core"))

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.lifecycle.runtime.ktx)
    implementation(libs.androidx.activity.compose)
    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.ui)
    implementation(libs.androidx.ui.graphics)
    implementation(libs.androidx.ui.tooling.preview)
    implementation(libs.androidx.material3)
    implementation(libs.androidx.material.icons.extended)
    androidTestImplementation(platform(libs.androidx.compose.bom))
    debugImplementation(libs.androidx.ui.tooling)
    debugImplementation(libs.androidx.ui.test.manifest)

    implementation(libs.play.service.auth)

    implementation(libs.hilt.android)
    ksp(libs.hilt.android.compiler)
    implementation(libs.androidx.hilt.navigation.fragment)
    implementation(libs.androidx.hilt.navigation.compose)
    ksp(libs.androidx.hilt.compiler)

    implementation(libs.androidx.navigation.compose)

    implementation(platform(libs.firebase.bom))
    implementation(libs.firebase.analytics)
    releaseImplementation(libs.firebase.crashlytics)
    implementation(libs.firebase.message)


    implementation(libs.coil.kt.coil.compose)
    implementation(libs.coil.svg)
    implementation(libs.lottie.compose)

    implementation(libs.richtext.commonmark)
    implementation(libs.richtext.ui.material3)

}

(Core module) build.gradle.kts

plugins {
    alias(libs.plugins.android.library)
    alias(libs.plugins.jetbrains.kotlin.android)
    id("com.google.dagger.hilt.android")
    id("com.google.devtools.ksp")
    id("androidx.room")
}

android {
    namespace = "com.atech.core"
    compileSdk = 34

    defaultConfig {
        minSdk = 24

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles("consumer-rules.pro")

        room {
            schemaDirectory("$projectDir/schemas")
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)

    implementation(libs.androidx.room.ktx)
    ksp(libs.androidx.room.compiler)
    implementation(libs.gson)

    implementation(libs.hilt.android)
    ksp(libs.hilt.android.compiler)


    implementation(platform(libs.firebase.bom))
    implementation(libs.firebase.analytics)
    releaseImplementation(libs.firebase.crashlytics)
    implementation(libs.firebase.firestore)
    implementation(libs.firebase.auth)

}

lib.version.toml

[versions]
agp = "8.4.0"
hiltAndroidCompiler = "2.51.1"
hiltAndroidVersion = "2.51.1"
hiltNavigationFragment = "1.2.0"
kotlin = "1.9.24"
coreKtx = "1.13.1"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
lifecycleRuntimeKtx = "2.7.0"
activityCompose = "1.9.0"
composeBom = "2024.05.00"
ksp-version = "1.9.24-1.0.20"
hiltAndroid = "2.51.1"
hiltAndroidPlugin = "2.50"
navigationCompose = "2.7.7"
roomKtx = "2.6.1"
roomVersion = "2.6.1"
junitJunit = "4.13.2"
androidxJunit = "1.1.5"
espressoCoreVersion = "3.5.1"
appcompat = "1.6.1"
material = "1.12.0"
firebaseBom = "33.0.0"
googleGmsGoogleServices = "4.4.1"
googleAndroidLibrariesMapsplatformSecretsGradlePlugin = "2.0.1"
materialIconsExtended = "1.6.7"
gson-version = "2.10.1"
coilCompose = "2.6.0"
lottieCompose = "6.4.0"
richtextCommonmark = "0.20.0"
play-service-auth = "21.1.1"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltNavigationFragment" }
androidx-hilt-navigation-fragment = { module = "androidx.hilt:hilt-navigation-fragment", version.ref = "hiltNavigationFragment" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigationFragment" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomKtx" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "roomKtx" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltAndroid" }
junit = { group = "junit", name = "junit", version.ref = "junitJunit" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended", version.ref = "materialIconsExtended" }

firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics" }
firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics" }
firebase-firestore = { group = "com.google.firebase", name = "firebase-firestore" }
firebase-auth = { group = "com.google.firebase", name = "firebase-auth" }
firebase-message = { group = "com.google.firebase", name = "firebase-messaging" }

gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson-version" }

coil-kt-coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilCompose" }
coil-svg = { module = "io.coil-kt:coil-svg", version.ref = "coilCompose" }
lottie-compose = { module = "com.airbnb.android:lottie-compose", version.ref = "lottieCompose" }

richtext-commonmark = { module = "com.halilibo.compose-richtext:richtext-commonmark", version.ref = "richtextCommonmark" }
richtext-ui-material3 = { module = "com.halilibo.compose-richtext:richtext-ui-material3", version.ref = "richtextCommonmark" }

play-service-auth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "play-service-auth" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp-version" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hiltAndroidPlugin" }
android-library = { id = "com.android.library", version.ref = "agp" }
googleAndroidLibrariesMapsplatformSecretsGradlePlugin = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "googleAndroidLibrariesMapsplatformSecretsGradlePlugin" }

Environment Details:

  • Android Studio version: Android Studio Koala | 2024.1.1 Nightly 2024-05-08
  • Gradle version: 8.7
  • Android Gradle Plugin version: 8.4.0
  • Target Android version: 34

I was expecting the task to complete successfully and generate an optimized and obfuscated release APK file for my application. However, instead of generating the APK, the build process failed with the error.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật