hello!
I’ve been trying to add Hilt in my app but I run into this issue when building:
Execution failed for task ‘:app:hiltJavaCompilePreprod’.
java.lang.NullPointerException: Cannot invoke “dagger.spi.shaded.androidx.room.compiler.processing.XTypeElement.getAnnotation(com.squareup.javapoet.ClassName)” because the return value of “dagger.spi.shaded.androidx.room.compiler.processing.XProcessingEnv.findTypeElement(com.squareup.javapoet.TypeName)” is null
I am wondering if there is something wrong in my gradle configuration…
Part of my root gradle:
ext.kotlin_version = '1.8.0'
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'io.realm:realm-gradle-plugin:10.4.0'
classpath 'com.google.gms:google-services:4.3.13'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.7.0.300'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.48'
}
//hilt
hiltCompiler: 'com.google.dagger:hilt-android:2.48',
hiltKapt: 'com.google.dagger:hilt-android-compiler:2.48'
part of my app gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
implementation dmaDependencies.hiltCompiler
kapt dmaDependencies.hiltKapt
I am using jetbrains runtime 17.
Thanks
Gianpaolo