I want to use architecture project (todo list) but get this error when i want to run project
The project is using an incompatible version (AGP 7.3.0-alpha07) of the Android Gradle plugin. Latest supported version is AGP 7.2.1
Try either to upgrade Android Studio or change AGP version to the stable version like for example 7.2.1 in the project's build.gradle file and sync the project:
buildscript {
//...
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
// ...
}
}
You can refer this table, that lists which version of Gradle is required for each version of the Android Gradle plugin.
Or this table that lists which version of the Android Gradle plugin is required for each version of Android Studio.
Instead of downgrading your AGP version in the accepted answer, you can update your android studio.
go to File > Settings and Update Android Studio
Update to the latest version of Android Studio i.e. Dolphin and your problem will be resolved
buildscript {
ext.kotlinVersion = '1.6.10'
ext.navigationVersion = '2.4.2'
ext.ktlintVersion = '0.44.0'
ext.hiltVersion = '2.42'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Setting the versions in the top-level build.gradle as seen above, worked for me.
It is important to change the kotlinVersion as well!
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
In plugins change the version according to other projects use in your android studio check that and change according to them it will work.
Update your Android Studio to the latest Android Studio (Dolphin version) version.
When building gradle I'm getting this message:
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'
I'm using Android Studio 4.1 Canary 10 and gradle:4.1.0-alpha10
It seems like the Navigation Safe Args plugin uses getApplicationIdTextResource(), so it is most likely that the error message is caused by your usage of that plugin.
You'd want to star the existing issue to ask the Safe Args plugin to use the new replacement API.
Changing to androidx.navigation:navigation-*:2.4.0-alpha02 as described here allowed a build of my app under Arctic Fox without getting the getApplicationIdTestResource warning
From the application build.gradle file:
def nav_version = "2.4.0-alpha02"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
And in the build.gradle file:
def nav_version = "2.4.0-alpha02"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
few days i see the same issue. Then i go to ->
build.gradle file
My Dependencies before update
check the dependencies
I update the dependencies google services to 4.3.4
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
After update
Now its working fine.
This error was for NavigationComponent for me in Android Studio Cannery 13.
So I changed the nav_version to this and My issue was solved.
ext {
*************** nav_version = "2.4.0-alpha10" ************
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0-alpha13'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
and in app module build.gradle:
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
It will be solved, when 4.2.0 is stable.
From the existing issue:
Android Gradle Plugin deprecated the getApplicationIdTextResource()
API on the class BaseVariant in version 4.1.0 (see bug). The
replacement API (onVariantProperties) did not work properly for
feature libraries, so to avoid the deprecation warning, reflection was
used. That is only a short term solution, and when AGP 4.2.0 is stable
we should update to that version and remove the reflection immediately
So if you need Safe Args and do not need latest features of Gradle, keep Gradle version in Android Gradle Plugin version at 3.6.4. Once stable 4.2.0 released, update to the latest.
This error happened after i updated kotlin version to 1.7.
this was for NavigationComponent in Android Studio
So I changed the nav_version to this and My issue was solved : "2.4.0-beta02"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.4.0-beta02"
implementation "androidx.navigation:navigation-ui-ktx:2.4.0-beta02"
For me it was because of different Kotlin versions between IDE Kotlin plugin and project_name/build.gradle file
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
"Kotlin version that is used for building with Gradle (1.3.72) differs from the one bundled into the IDE plugin (1.4.31) "
Once I made it even it started to compile again.
In my case I was using 2.3.1 version of navigation-fragment.
I just updated it to 2.4.2 and it's helped me
So, What i have done is that I have upgraded all the gradle plugins as well as dependecies versions and then run, It worked for me
I had the same problem and it was solved like this:
So I go to -> build.gradle file
My dependencies before upgrade
check the dependencies
I update Google services dependencies to latest version
dependencies {
classpath 'com.android.tools.build:gradle:(latest version)'
classpath 'com.google.gms:google-services:(latest version)'
}
Android Studio 4.1 giving the following information and It will be removed in version 5.0 of Android Gradle Plugin.
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see TBD.
To determine what is calling BaseVariant.getApplicationIdTextResource, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
As #ianhanniballake has pointed out, it seems likely that it's caused by the Navigation Safe Args plugin, see the existing issue, also referenced from his answer. The issue was marked as fixed on 9 November.
In terms of fixing the build error, upgrading Android Studio from 4.1.0 to 4.1.1 fixed it for me.
delete the .idea and .gradle files from the project .. it worked with me
I updated my AS from 3.0 to 3.1. After fixing several issues that showed up with the update, I am stuck at making Kotlin work.
Kotlin code compiles and runs, although I can't edit kotlin files. Kotlin keywords are not recognised by the editor, using kotlin code from java classes appear red and in general I can't really do anything with kotlin.
I use:
buildscript {
ext.kotlin_version = '1.2.41'
...
...
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
kotlin plugin: 1.2.41-release-Studio3.1-1
and org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version
In gradle I do not use dynamic versions because that could lead to indeterminate builds.
So I state my dependencies like so:
compile 'com.squareup.okhttp:okhttp:2.2.0'
However, how do I find out if there is a new version available and what its number is?
You can use a gradle-versions-plugin to do it. This plugin provides a dependencyUpdates task, which
Displays a report of the project dependencies that are up-to-date, exceed the latest version found, have upgrades, or failed to be resolved.
All you need to do, is to apply, by configuration of build.script dependencies, as:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
// classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5' // uncomment if you're using Gradle 1.x
}
}
And applying the plugin itself, with:
apply plugin: 'com.github.ben-manes.versions'
You could use this site to search your library latest version.
Updated 21.06.2015
I wanna try kotlin and android databinding in a same project. But when I add to kotlin-gradle-plugin dependency I cannot build even an empty project anymore with error:
cannot generate view binders java.lang.NoClassDefFoundError: kotlin/jvm/internal/ExtensionFunctionImpl
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta3'
classpath "com.android.databinding:dataBinder:1.0-rc0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.613"
}
}
Any workaroud to make it work together?
Unfortunately,this is caused by a kotlin version inconsistency between databinding and kotlin plugin.
We'll remove kotlin dependency from the plugin on rc1 but until then you would need to use kotlin 0.11.91.
Also, since kotlin's annotation processor support is limited at this moment and data binding is using annotation processor; they probably won't work well (though I have not tried).