'New build.gradle in Android Studio Bumblebee | 2021.1.1 Beta 5 error adding dependencies
I updated Android Studio and now in top level build.gradle there is no dependencies scope, instead there is plugins scope. And I want to add the dependency for navigation safe args. In old versions, I was able to add like:
dependencies {
def nav_version = "2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
But now we have plugins scope.
plugins {
id 'com.android.application' version '7.2.0-alpha02' apply false
id 'com.android.library' version '7.2.0-alpha02' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false }
And I added safe-args plugin to this scope
id "androidx.navigation:navigation-safe-args-gradle-plugin" version "2.3.5" apply false
, but I get this error:
plugin id 'androidx.navigation:navigation-safe-args-gradle-plugin' is invalid: Plugin id contains invalid char ':'
Solution 1:[1]
I had the same problem.
What I did was add the dependencies wrapper inside the buildscript wrapper and it worked for me.
Example:
buildscript {
ext {
compose_version = '1.0.5'
}
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
}
}// Top-level build file where you can add configuration options common
to all sub-projects/modules.
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.5.31' apply false
id "com.google.dagger.hilt.android" version '2.41' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Solution 2:[2]
Add a buildscript group to the top of the build.gradle(Project) file.
buildscript {
dependencies {
classpath("androidx.navigation.safeargs:androidx.navigation.safeargs.gradle.plugin:2.4.1")
}
}
Then add the plugin ID to the plugins group in the build.gradle(Module) file.
id 'androidx.navigation.safeargs'
Make sure the line android.useAndroidX=true is in gradle.properties.
That will do it.
Solution 3:[3]
- Open
build.gradle(Module:app) - Use
Strg+Alt+Shift+Sto open Project Structure dialog - Search for androidx.navigation
- Select
androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0-rc01 - Apply and wait for sync
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 | Nafis Kabbo |
| Solution 2 | Phil |
| Solution 3 | Zoe stands with Ukraine |
