How to add plugins in the Android Studio Bumblebee
Asked Answered
L

4

3

I want to add dagger-hilt plugin to project.

 classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'

https://developer.android.com/studio/preview/features#settings-gradle

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

task clean(type: Delete) {
  delete rootProject.buildDir
}
pluginManagement {
  repositories {
    gradlePluginPortal()
    google()
    mavenCentral()
  }
}

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    google()
    mavenCentral()
  }
}
rootProject.name = 'GradleManagedDeviceTestingNew'
include ':app'
Lechery answered 10/1, 2022 at 10:31 Comment(0)
U
6

This is the correct to using the classpath in bumblebee

Use buildscript before plugins it will work and put your classpath there in the dependencies block

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


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



task clean(type: Delete) {
    delete rootProject.buildDir
}
Unlettered answered 28/1, 2022 at 17:19 Comment(1)
Thanks it works, I've just tried!Kiushu
M
3

You should add a resolutionStrategy to settings.gradle as below.

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }

    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == 'dagger.hilt.android.plugin') {
                useModule("com.google.dagger:hilt-android-gradle-plugin:2.40.5")
            }
        }
    }
}

Then, add the hilt plugin as below to the module level build.gradle file, it was updated correctly.

plugins{
  *****
  id 'dagger.hilt.android.plugin'
}
Milinda answered 16/1, 2022 at 12:38 Comment(1)
Thx. You are right!Lechery
S
1

When creating a new project in AS BubmleBee the dependencies block is missing in top-level gradle file

To resolve adding classpath dependencies you should add the following block within the buildscript block.

 dependencies {
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.40.5"

    }
Selectman answered 25/1, 2022 at 23:49 Comment(0)
M
1

Add the following id in the plugins section of the top level gradle file:

id 'com.google.dagger.hilt.android' version '2.42' apply false

Credits to this SO answer

Material answered 8/7, 2022 at 22:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.