Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find AGP version in build files & empty Android Gradle Plugin Version

Android Studio Upgrade Assistant recommends to update Android Gradle Plugin from version 7.0.0. to x.x.x. However, the problem is that it alerts "Cannot find AGP version in build files". I'm struggling with this message and I found the empty AGP version in my project structure. I've already checked

gradle-7.3-bin

inside

C:\Users\abc.gradle\wrapper\dists' and allocated 'Gradle user home' as 'C:\Users\abc\.gradle.

That dropdown button below the 'Android Gradle Plugin Version' has nothing and I want to find out why and how to fix it. Is this related with the AGP upgrade?

Attachment

like image 906
John99 Avatar asked May 20 '26 22:05

John99


1 Answers

I got the same error when in Android Studio I tried to use Tools > AGP Upgrade Assistant.

For those who don't know, the Android Gradle Plugin is the dependency com.android.tools.build:gradle: specified in the project-level build.gradle (to be clear, not my module-level build.gradle).

In my case, the problem was that my project-level build.gradle file specified the version of the Android Gradle Plugin using a variable rather than hardcoding the version.

My project had the following variable in my gradle.properties and referenced it in my build.gradle file:

gradle_version=7.2.2

It referenced it in the project-level build.gradle file like this:

classpath "com.android.tools.build:gradle:$gradle_version"

To fix the problem, I changed my project-level build.gradle file from this:

classpath "com.android.tools.build:gradle:$gradle_version"

To this:

classpath 'com.android.tools.build:gradle:7.3.1'

After that change, Tools > AGP Upgrade Assistant stopped complaining "Cannot find AGP version in build files". Furthermore, I was able to use AGP Upgrade Assistant to upgrade from com.android.tools.build:gradle:7.2.2 to com.android.tools.build:gradle:7.3.1.

like image 76
Michael Osofsky Avatar answered May 22 '26 11:05

Michael Osofsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!