我在尝试为 Android 应用程序生成发布版本或运行 gradle :app:minifyReleaseWithR8 任务时遇到问题。 我的Android项目有两个模块:
app
和core
构建过程失败,并显示如下错误消息:
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)
我已尝试以下步骤来解决该问题:
但是,到目前为止,这些步骤都没有解决问题。
这是我的(应用程序模块)
build.gradle.kts
文件
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" }
环境详情:
我希望任务能够成功完成,并为我的应用程序生成一个经过优化和混淆的发布 APK 文件。但是,构建过程没有生成 APK,而是失败并出现错误。
尝试从库模块中删除 isMinifyEnabled=true 。