I always get this error: `The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-an...
a
I always get this error:
The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android dependency was found.
I wan't to use Hilt with Jetpack Compose but always I got this error
s
paste whole file
f
Which gradle version are you using?
a
@FunkyMuse
Copy code
7.0.0-beta05
f
i think you need to update to 7.0.3 alpha, there was some problem with the gradle thing not working with the 7.0.X betas look it up
a
So I change this to 7.0.3-alpha ?
s
this may not be hilt issue at all
this error message shows up when there is any error in gradle script
and it obfuscates the real error
a
what I have to do ?
I did figure how to update to Gradle 7.0.3 alpha any help ?
f
classpath 'com.android.tools.buildG7.1.0-alpha03'
❤️ 1
s
try to comment out hilt plugin line at the top, also hilt block if you use it, then sync again. there is a chance there will be another error
a
@solidogen It sync normally when I add the plugin this error show
s
okay, make sure you also included all hilt dependencies in dependencies block in app module’s build.gradle.kts
a
I use
build.gradle
not
build.gradle.kts
s
sure, this should not matter
a
The problem show always when apply this plugin
s
paste whole file here
at least dependencies block
a
Copy code
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}


android {
    compileSdk 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.akram.bensalem.powersh"
        minSdk 21
        targetSdk 30
        versionCode 1
        versionName "1.0"

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

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '<http://proguard-rules.pro|proguard-rules.pro>'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions {
            jvmTarget = '1.8'
            useIR = true
            freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
        }

    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"

    implementation "androidx.compose.ui:ui-tooling:1.0.0-beta09"

    implementation 'com.jakewharton.timber:timber:4.7.1'

   implementation("androidx.datastore:datastore-preferences:1.0.0-rc01")


    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-rc01'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"








    implementation 'com.google.android.material:material:1.4.0'


    implementation "androidx.compose.foundation:foundation:$compose_version"
    // Material design icons
    implementation "androidx.compose.material:material-icons-core:$compose_version"
    implementation "androidx.compose.material:material-icons-extended:$compose_version"
    // Integration with activities
    implementation 'androidx.activity:activity-compose:1.3.0-rc01'
    // Integration with ViewModels
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'
    // Integration with observables

    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation "androidx.compose.runtime:runtime-rxjava2:$compose_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"

    implementation "androidx.navigation:navigation-compose:2.4.0-alpha04"


    implementation "androidx.compose.compiler:compiler:$compose_version"

    implementation 'androidx.palette:palette-ktx:1.0.0'

    implementation "androidx.compose.material:material-icons-extended:$compose_version"

    implementation 'dev.chrisbanes.accompanist:accompanist-coil:0.3.3.1'

    // UI Tests
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

    implementation "com.airbnb.android:lottie-compose:1.0.0-rc01-1"

    //Accompanist
    implementation "com.google.accompanist:accompanist-systemuicontroller:0.12.0"
    implementation "com.google.accompanist:accompanist-pager:0.12.0"
    implementation "com.google.accompanist:accompanist-pager-indicators:0.12.0"
    implementation "com.google.accompanist:accompanist-coil:0.12.0"
    implementation "com.google.accompanist:accompanist-swiperefresh:0.12.0"
    implementation "com.google.accompanist:accompanist-insets:0.12.0"
    // If using insets-ui
    implementation "com.google.accompanist:accompanist-insets-ui:0.12.0"


    implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha08'
    implementation 'com.google.code.gson:gson:2.8.6'


    implementation "com.github.skydoves:orchestra-balloon:1.0.7"
}
@solidogen
s
you don’t have hilt dependencies
🙂
a
@FunkyMuse same error even after update to 7.1.0-alpha03
f
then include the hilt dependencies 😄
s
follow Using hilt with kotlin
a
@solidogen @FunkyMuse The old error disapear and the project sync normally but I got this 😭
f
now you have to learn Dagger/Hilt @Akram Bensalem
1
a
So every thing it works ?
Thank you so much for your time ❤️
1221 Views