'error gradle when update to bumblebee android studio version

today, i update to bumblebee android version, and i create new project and i import some lib, include dagger-hilt. in build.gradle (module) i insert:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
    id 'androidx.navigation.safeargs'
}

dependencies {
...
 implementation "com.google.dagger:hilt-android:2.38.1"
    kapt "com.google.dagger:hilt-compiler:2.38.1"
    androidTestImplementation  "com.google.dagger:hilt-android-testing:2.38.1"
    kaptAndroidTest "com.google.dagger:hilt-compiler:2.38.1"
    testImplementation "com.google.dagger:hilt-android-testing:2.38.1"
    kaptTest "com.google.dagger:hilt-compiler:2.38.1"
}

and in build.gradle (project) i insert:

plugins {
    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    id 'androidx.navigation.safeargs.kotlin' version '2.4.0-beta02' apply false
    id 'dagger.hilt.android.plugin' version '2.38.1' apply false
}

but android studio build fail:

Build file 'H:\AndroidProject\WMTWorkmanagerTodolist\build.gradle' line: 7

Plugin [id: 'dagger.hilt.android.plugin', version: '2.38.1', apply: false] was not found in any of the following sources:

  • Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Exception is: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'dagger.hilt.android.plugin', version: '2.38.1', apply: false] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Plugin Repositories (could not resolve plugin artifact 'dagger.hilt.android.plugin:dagger.hilt.android.plugin.gradle.plugin:2.38.1') Searched in the following repositories: Gradle Central Plugin Repository Google MavenRepo

why? how do i can fix it. Thank for support.



Solution 1:[1]

You can just add the buildscript block with dependencies in them on top of the plugins block:

buildscript {
  dependencies {
    classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'
  }
}

plugins {
  id 'com.android.application' version '7.1.0' apply false
  id 'com.android.library' version '7.1.0' apply false
  id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

Solution 2:[2]

enter image description here I copied the old version and it works fine

Solution 3:[3]

Add this classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5' to your project build.gradle file or read this https://dagger.dev/hilt/gradle-setup.html#hilt-gradle-plugin

Solution 4:[4]

I solved it with this answer https://stackoverflow.com/a/70556278/5332110

Also make sure you're using this version of Kotlin:

id 'org.jetbrains.kotlin.android' version '1.5.31' apply false

Additional information: https://developer.android.com/studio/releases/gradle-plugin?buildsystem=ndk-build#settings-gradle

Solution 5:[5]

  1. Add this line to the project build.gradle:
plugins {

    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'com.google.gms.google-services' version '4.3.0' apply false ?
}

task clean(type: Delete) {

    delete rootProject.buildDir
}
  1. add this line to the app build.gradle:
plugins {

    id 'com.android.application'
    id 'com.google.gms.google-services' ?
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JWL
Solution 2 sonpxp
Solution 3 OneDev
Solution 4 Alejandra
Solution 5 ChrisMM