Closed dgaillard2 closed 3 months ago
Hi @dgaillard2, are you able to reproduce this in a minimal repro example that you can share with us?
Yes i created this minimal repo project : https://github.com/dgaillard2/hiltTest
But sadly, i can't reproduce. HiltJavaCompileRelease works on this project, but it doesn't on my project. I can't understand why. I add step by step every think i have that "can be a problem" in this repo project, but can't reproduce.
What i have done in my project : removing all proguard rules but still have problem
What i have done in this minimal repo project :
As i explain above, logs doesn't explain a lot, do someone have an idea how i can isolate the problem or have better logs ? I try --stacktrace or --info but it doesn't say much, "annotation is null"
It s really weird because, it s specific to the upgrade of AGP from 8.3.2 to 8.4.2
8.3.2 -> no problems 8.4.2 -> problem
But .. On the minimal repro project i shared with u, there is no problem with the 8.4.2 AGP :') agp = "8.4.2" android-application = { id = "com.android.application", version.ref = "agp" }
We can add additional information to the error message to tell you which element it is failing on. That information might help you narrow down possible causes of the issue and help you repro it. I'm out until next Thursday, but I can make the changes once I'm back.
I appreciate, thanks :) My repo in error is a private repo company but if you tell me how i can add additional information to the error message, i will, thanks :)
Hello @bcorso, are you back ?
Yep, I'm back. The information should be added once the PR above is submitted. You can use the HEAD-SNAPSHOT
or wait for the next official Dagger release (early next week).
Thanks, i will keep you in touch with next dagger release
I upgrade to Dagger 2.52 and indeed i got more information :
error: [Hilt] Missing @AggregatedDeps annotation on hilt_aggregated_deps._com_decathlon_proglove_data_di_BindModule: java.lang.IllegalStateException: Missing @AggregatedDeps annotation on hilt_aggregated_deps._com_decathlon_proglove_data_di_BindModule at com.google.common.base.Preconditions.checkState(Preconditions.java:601) [Hilt] Missing @AggregatedDeps annotation on hilt_aggregated_deps._com_decathlon_proglove_data_di_BindModule: java.lang.IllegalStateException: Missing @AggregatedDeps annotation on hilt_aggregated_deps._xxx_di_BindModule
This android module have got an hilt module (others android modules have hilt module too), but this one seems to be in error. After analyse, i don't understand why, as explain on the original post, all works before upgrade :)
This hilt module of the error is like this :
@Module
@InstallIn(SingletonComponent::class)
@Suppress("unused")
abstract class BindModule {
@Binds
abstract fun bindRepository(impl: XxxxRepositoryImpl): XxxxRepository
}
There is one difference with others android modules, this proguard rules :
-dontwarn java.lang.invoke.StringConcatFactory
But this one seems mandatory for a library i'm using :
minifyReleaseWithR8 :
AGPBI: {"kind":"error","text":"Missing class java.lang.invoke.StringConcatFactory (referenced from: void com.decathlon.proglove_data.ProgloveRepositoryImpl.onBarcodeScanned(de.proglove.sdk.scanner.BarcodeScanResults) and 1 other context)","sources":[{}],"tool":"R8"}
Hmm, can you find the hilt_aggregated_deps._com_decathlon_proglove_data_di_BindModule
class and ensure that the @AggregatedDeps
annotation is actually there?
If it is there in the generated source and you're still getting that error it means the annotation is getting stripped. Are you running proguard/r8 over the library separately from your application?
Here it is :
/**
* This class should only be referenced by generated code! This class aggregates information across multiple compilations.
*/
@AggregatedDeps(
components = "dagger.hilt.components.SingletonComponent",
modules = "com.decathlon.proglove_data.di.BindModule"
)
@Generated("dagger.hilt.processor.internal.aggregateddeps.AggregatedDepsGenerator")
public class _com_decathlon_proglove_data_di_BindModule {
}
Indeed AgreegatedDeps is there and i have define proguard inside the build.gradle.kts of this android module :
buildTypes {
debug {
}
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
My application module have his own proguard :
buildTypes {
debug {
}
release {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
isDebuggable = false
}
}
Thanks
Sorry @bcorso i don't understand, maybe we close it too fast, as explained i need inside my proguard module this line :
-dontwarn java.lang.invoke.StringConcatFactory
But with the new version of hilt, it s not possible to have this line ?
How can i solve this ?
I think @bcorso meant to link https://github.com/google/dagger/issues/4384#issuecomment-2286926240 when he closed this.
Ok thank you, i will remove minify from library module šš»
It's strange, my project works well, but when i upgrade from my AGP like this :
from
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip com.android.tools.build:gradle 8.3.2
todistributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip com.android.tools.build:gradle 8.4.2
i get this error in my project :
I'm using
com.google.dagger:hilt-compiler:2.49
andcom.google.dagger:hilt-android:2.49
I found this issue : https://github.com/google/dagger/issues/4241
What i tried :
com.google.dagger:dagger-producers
but it didn't resolve the problemIt happens on
hiltJavaCompilePreprodRelease
but it works onhiltJavaCompilePreprodDebug
Any idea why upgrading my AGP cause this problem ?
Thanks