2

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.

lbarqueira
  • 1,101
  • 1
  • 10
  • 28
  • Does this answer your question? [How to add plugins in the Android Studio Bumblebee](https://stackoverflow.com/questions/70650972/how-to-add-plugins-in-the-android-studio-bumblebee) – Luis Ángel Berríos Jul 09 '22 at 11:43

5 Answers5

2

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
}
JWL
  • 63
  • 3
  • 12
1

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

sonpxp
  • 21
  • 2
0

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

OneDev
  • 557
  • 3
  • 14
0

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

Alejandra
  • 576
  • 6
  • 10
0
  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' 
}
ChrisMM
  • 8,448
  • 13
  • 29
  • 48
Noam Avni
  • 23
  • 5