So I am pretty new to Android Studio, and Android development; my background is Java fullstack.
I started by creating a default template from Android Studio and moved my code (and code from a dagger sample project, and sample code from the API I'm trying to implement).
In terms of classes and events I think I have everything correct, but my project is not compiling. When I say run with stack trace, the error I get is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'. ... Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.IllegalArgumentException: Invalid relative name: META-INF\proguard\com_inventoryscanner_ui_barcodescannerBarCodeScanningViewModel_HiltModules_BindsModule_LazyClassKeys.pro ... Caused by: java.lang.IllegalArgumentException: Invalid relative name: META-INF\proguard\com_inventoryscanner_ui_barcodescannerBarCodeScanningViewModel_HiltModules_BindsModule_LazyClassKeys.pro
I am using Android Studio Ladybug | 2024.2.1 Patch 3 Gradle 8.11.1 AGP 8.7.3 Java 11 SDK 35 Target 30
[libraries]
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hiltVersion" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hiltVersion" }
hilt-android-gradle-plugin = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "hiltVersion" }
dagger-android-processor = { group = "com.google.dagger", name = "dagger-android-processor", version.ref = "hiltVersion" }
[plugins]
dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hiltVersion" }
kotlin = "2.0.0"
hiltVersion = "2.53"
App level
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.dagger.hilt.android) apply false
}
Module level
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.dagger.hilt.android)
kotlin("kapt")
}
android {
namespace = "com.inventoryscanner"
compileSdk = 35
defaultConfig {
applicationId = "com.inventoryscanner"
minSdk = 30
//noinspection ExpiredTargetSdkVersion
targetSdk = 30
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
resourceConfigurations += setOf()
proguardFiles()
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
viewBinding = true
}
buildToolsVersion = "35.0.0"
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.androidx.legacy.support.v4)
implementation(libs.androidx.fragment.ktx)
implementation(libs.hilt.android)
implementation(libs.hilt.android.gradle.plugin)
kapt(libs.dagger.android.processor)
kapt(libs.hilt.compiler)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
hilt {
enableAggregatingTask = true
}
kapt {
correctErrorTypes = true
}
The proguard-rules.pro file is empty, or at least everything in there is the default commented out template, I haven't touched it. But I have tried copying settings from some places that hasn't made a difference and then I reverted them.
I've searched online high and low and have tried changing versions, settings, all to no avail. But I'm new to Android Studio, so I'm not sure if I'm missing something obvious.
So my steps to reproduce are:
Kotlin
2.1.0
, using kapt
for Hilt processor
Dagger
and Hilt
2.53
ViewModel
injected with Hilt
Fix is:
Dagger
and Hilt
to 2.52
Kotlin
to 2.0.21
I think this can be a related issue. Seems that its going to be fixed in 2.53.1