https://kotlinlang.org logo
#dagger
Title
# dagger
a

Akram Bensalem

07/13/2021, 2:10 PM
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

solidogen

07/13/2021, 3:16 PM
paste whole file
f

FunkyMuse

07/14/2021, 6:44 AM
Which gradle version are you using?
a

Akram Bensalem

07/14/2021, 8:06 AM
@FunkyMuse
Copy code
7.0.0-beta05
f

FunkyMuse

07/14/2021, 8:06 AM
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

Akram Bensalem

07/14/2021, 8:09 AM
So I change this to 7.0.3-alpha ?
s

solidogen

07/14/2021, 8:11 AM
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

Akram Bensalem

07/14/2021, 8:11 AM
what I have to do ?
I did figure how to update to Gradle 7.0.3 alpha any help ?
f

FunkyMuse

07/14/2021, 8:12 AM
classpath 'com.android.tools.buildG7.1.0-alpha03'
❤️ 1
s

solidogen

07/14/2021, 8:13 AM
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

Akram Bensalem

07/14/2021, 8:14 AM
@solidogen It sync normally when I add the plugin this error show
s

solidogen

07/14/2021, 8:16 AM
okay, make sure you also included all hilt dependencies in dependencies block in app module’s build.gradle.kts
a

Akram Bensalem

07/14/2021, 8:17 AM
I use
build.gradle
not
build.gradle.kts
s

solidogen

07/14/2021, 8:18 AM
sure, this should not matter
a

Akram Bensalem

07/14/2021, 8:19 AM
The problem show always when apply this plugin
s

solidogen

07/14/2021, 8:19 AM
paste whole file here
at least dependencies block
a

Akram Bensalem

07/14/2021, 8:20 AM
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

solidogen

07/14/2021, 8:20 AM
you don’t have hilt dependencies
🙂
a

Akram Bensalem

07/14/2021, 8:20 AM
@FunkyMuse same error even after update to 7.1.0-alpha03
f

FunkyMuse

07/14/2021, 8:21 AM
then include the hilt dependencies 😄
s

solidogen

07/14/2021, 8:21 AM
follow Using hilt with kotlin
a

Akram Bensalem

07/14/2021, 8:32 AM
@solidogen @FunkyMuse The old error disapear and the project sync normally but I got this 😭
f

FunkyMuse

07/14/2021, 8:32 AM
now you have to learn Dagger/Hilt @Akram Bensalem
1
a

Akram Bensalem

07/14/2021, 8:33 AM
So every thing it works ?
Thank you so much for your time ❤️
571 Views