Android studio preview 0.4.5: The project is using an unsupported version of the Android Gradle plug-in - android-studio

I got the following error message when I was importing a project from github:
Failed to refresh Gradle project 'XXX'
The project is using an unsupported version of the Android Gradle plug-in.
Fix plug-in version and re-import project
This is not a duplicate of this because your get thee error message before
gradle/wrapper/gradle-wrapper.properties
is generated.

The problem appeared after updates. The updated Android Gradle plug-in did not support the outdated version of Gradle I had. But the error message is misleading, if you don't attempt different build options you won't see what the problem is.
After downloading a newer version of Gradle, Imported the project again, then:
Use local gradle distribution
Then Gradle home set to the folder where the new version of gradle was downloaded
that solved it
Edit: From Scott (below comments) : It's preferable to use the wrapper and to change the Gradle version in gradle-wrapper.properties instead of downloading and installing Gradle yourself. As for the Android-Gradle plugin, that's set in the dependencies.classpath block in your build file; see this

I get this gradle-errors in 4 Studio updates! My solution: I copy the Studio-folder, and if gralde throws an error, I copy the old version back. It's not a good way, but until google is not able to deliver an update without producing always the same errors (even if mentioned in many forums), I stay on 4.9 and wait for the first final release.

Related

Could not find com.android.tools.build:gradle:7.5.1

So I was building out a test APK in Android Studio tonight that had to be signed. It failed and said my Gradle was out of date. So I upgraded my gradle from 7.3.3 to the newest 7.5.1
I changed the wrapper setting to distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
and then I changed my build.gradle dependency to classpath 'com.android.tools.build:gradle:7.5.1'
Note that after doing the changes, and restarting Android Studio, it did upgrade the version in the app directory.
Here's the error getting thrown below:
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.5.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.5.1/gradle-7.5.1.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.5.1/gradle-7.5.1.pom
Required by:
project :
Note that this was a project from a client, and I did not write this originally. These dependencies were in place, but fairly recent, and the app would build fine with it using 7.3.3. However it wouldn't let me sign my app.
I suppose I could use some wisdom on both of these issues. What I'm going to do is go back to version 7.3.3, build the signed APK again, and copy that exact error to report back here with. It was a gradle version error.
For any any Flutter noobs like myself passing through, this error occured because the Android Tools Plugin version DOES NOT match the Gradle Version:
https://developer.android.com/studio/releases/gradle-plugin#groovy
They match up just vaguely enough in number, that you would think that my line com.android.tools.build:gradle:7.5.1. uses gradle 7.5.1, but instead, Android Tools for Gradle is actually a separate entity, and at 7.3.3 as of typing this reply.
So you CAN set your Gradle to the newest version somewhere else in your project, but it has to match the compatible Android Tools version, which is set here. Its silly and confusing at first, and can easily trip up newcomers. Hopefully the versions diverge enough, or the code syntax changes for some better clarity, but as of now, this is it.

This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer

This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer.
but my android studio version is 3.2.1 and there is no new update from Google
Try to edit your project build.gradle file and set the android build gradle plugin to classpath 'com.android.tools.build:gradle:3.2.1' within the dependency section.
See also the documentation of the android grade plugin
It's a bit late, But easy and effective.
Click on About Android Studio,
Check the current version,
Open build.gradle of Project and put it in front of the class path. e.g Your studio version is 3.5.2, then your classpath should look like this
classpath 'com.android.tools.build:gradle:3.5.2'
You would need to lower your gradle version and android plugin version, or you can download latest version from beta or canary update channels.
To enable updates from other channels go to Help -> Check for Updates -> Congifure automatic updates and in that dialog select channel you want. After selecting check for update again and it will show you latest version.
This issue is caused due to use of newer version of gradle in the project.
There are two options to resolve this:
Option 1:
Change gradle/wrapper/gradle-wrapper.properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Change project level gradle build.gradle file
classpath("com.android.tools.build:gradle:3.3.2")
Option 2:
Update your Android Studio to newer version. (Highly recommended)
In IntelliJ IDEA this is an open bug: https://youtrack.jetbrains.com/issue/IDEA-252823
As a workaround, you can change the build tools version as other people advise.
My project was failing with this dependency:
com.android.tools.build:gradle:7.0.0-alpha03
Now it's working with this:
com.android.tools.build:gradle:4.0.2
As a side note, you should change that dependency in build.gradle in some projects or in dependencies.kt in newer projects.
That was the most updated version that worked.
After an update the Android Studio does not show the layout's design for some reason. I tried newer versions as well, but it did not work. So I decided to downgrade my IDE.
When I opened my project, I got the same error. The solution was the following:
Open the Project Structure.
Select the Project field.
Use the appropriate Android Plugin Version. You can copy it from a new project's structure.
Change the Gradle version too what you need.
OK.
Find the gradle-wrapper.properties file and open it.
Change the distributionUrl to that gradle version url what you saved in the Project Structure.
Or if you don't mind, then you can update your AS.
Had the same Issue when i decided to install another version of Android Studio, what worked for me was:
Creating a new project with the current version of Android Studio just to go check the classpath version at the project level build.gradle inside the dependencies section, at the time it was this:
classpath 'com.android.tools.build:gradle:3.5.0-rc01'
Copied that line and replaced it on the project i was working on.
in project's build.gradle file comment classpath com.android.tools.build:gradle:. File → Project Structure select Android Gradle Plugin Version to match Android Studio version
You can now update your android studio to 3.4 stable version. Updates for stable version are now available. cheers!!!
i just change gradle version classpath 'com.android.tools.build:gradle:3.5.3' to
classpath 'com.android.tools.build:gradle:3.3.2' and now working.
I encountered with this error and just decrease gradle version and android plugin version to 5.1.1 and 3.4.2.
Close VPN worked for me! It suprised me.
this issue occur for me after downgrade Java JDK, after upgrade JDK my problem resolved.
Open android studio then go to help menu > check for update > Update your Android Studio to newer version.
If u r here because of Jetpack Compose, I had the same problem, and solved it by using the Arctic Fox Canary build of Android studio: you can download it at this link: https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2020.3.1.12/android-studio-2020.3.1.12-mac.zip
This issue arises due to updates, You can resolve this by downgrading the gradle used from
com.android.tools.build:gradle:3.2.1 to a previous gradle like com.android.tools.build:gradle:3.0.0 or anything older than the current one
This usually happens when you're opening someone else's project after unzipping it. And the person has used an updated android Studio.
The way to solve it is
1.Go to Help and about to see your android studio version
2.Go to File>Project Structure> and set your Android Gradle Plugin version to your android studio version
3.Change the Gradle version to the one you usually use.(optional)
Build the project and it should run without any errors
This seems like incompatible gradle plugin vs gradle binary versions. You can find the releases here: Gradle Plugin release and compatiblity
Upgrade your grade plugin and grade binary to compatible versions and the app should start building.

Android Studio “cannot resolve symbol R” but project compiles and runs

Android Studio displays in all java files in red : “cannot resolve symbol R” but the project compiles and runs.
I have tried every solution here:
Android Studio "cannot resolve symbol" but project compiles and works, but with no luck.
I tried to :
invalidate caches and restart android studio
delete .gradle and .idea folders
clean and rebuild the project
install a new version of android studio
mess up with gradle file then undo changes and sync project
One thing that I want to try, but I don't know how to achieve, is to reopen the project from scratch as I was opening it for the first time, but I don't know how to do this.
I also tried answers from here:
Android Studio says "cannot resolve symbol" but project compiles,
but again with no luck.
Android studio version = 3.2.1
dependency versions in gradle project file:
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
classpath 'com.google.gms:google-services:4.0.0'
For some reason that i do not understand ,
this combination of build versions made the issue :
grade version = 4.10.1
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
when i switched to these build versions :
grade version = 4.6
classpath 'com.android.tools.build:gradle:3.2.1'
The issue was solved !
File -> Close project
Open an existing Android Studio Project
Open you project
Hope it will work.
sometimes, R file is not generated because of package name on android manifest is not match with package module that you have.
Is any wrong syntax or spelling in your xml?
Check your layout or any xml file.
Android Studio seems to have a caching issue with R.java occasionally. I rarely have a problem with this, but when I do, I actually open R.java (double press shift and type "R.java") or navigate to R.java under "app/build/generated/source" directory, opening the file and checking if the relevant XML id has been created. If it has, it forces Android Studio to now recognise the id's that are not being resolved. It's quick to try, and doesn't require clean and rebuild.
From your programs menu, open android studio. instead of opening your project from the recent files, select to open a project from your computer and then locate the path to your project. When all else fails, sometimes this works.
Also, try commenting out the support libraries from your gradle implementation, sync your project, and after sync fails comment them back in and sync again. (not sure if that's what you tried already when you said you messed with the gradle file)
In my case,
I am using
- Android Studio version 3.3.1 at home
- Android Studio version 3.2.1 at office
When i pulled projects to my office computer that are firstly created at my home computer ,
Android Studio can not resolved R file but runs application with no error. Because projects gradle and Android Studio version are incompatible.
Only thing that you sholud do, change the gradle version in project level gradle file
classpath 'com.android.tools.build:gradle:3.3.1'
to
classpath 'com.android.tools.build:gradle:3.2.1'
I was facing same issue,
first thought the issue might because of some xml file or naming of drawable resources incorrectly. After analysing, this case wasn't applicable to me.
So
Updating Android studio from older version 3.2 to newer version 3.3.2 along with new build tool version from SDK manager resolved this issue
for me.
I've tried invalidate cache and Restart AS with clean rebuild all the options but didn't work for me.
It says cannot resolve symbol, but it can run.
In my case, I just reload the needed *.jar files to the libs folder.
File >> invalidate caches/restart
Rebuild Project
Sync
Run
Works for me!
It looks like the library did not load my "imports" properly the first time.
That's why the import methods cannot be seen in my main_activity.xml.
This happened to me when I was going back and forth between different SDK versions.
Apparently SDK manager copied all the source files but it didn't finish cleanly. As a result I could compile and run my project just fine but IDE didn't recognize the SDK and reported all java symbols unresolved.
None of the above and other solutions in SO didn't work for me, but just uninstalling/reinstalling the specific SDK version did a job.
If you renamed your package (inside java folder), make sure you change your Manifest package name to the same
The only thing that worked for me was,
replacing,
import package_name.R
with
import package_name.*
simply go to project settings : settings.gradel and change the rootProject.name to your current name
rootProject.name = "write the project name here"

Android Studio can't open project

I've recently get update notification of android studio 2.3, after the update it's not opening any project and throwing error:
[plugin: com.darkklord.gradle.metric.core]
after downgrading and reinstalling i still have this issue, can anyone please help me on this topic ?
Download latest plugin from here: https://plugins.jetbrains.com/plugin/9197-android-gradle-metrics--checkstyle
Install Plugin manually from disk.
Restart Android Studio (The error will still occur)
Remove plugin in IDE.
Restart
You might also uninstall the refrenzed plugins Checkstyle and PMD
You need to change your dependency
classpath 'com.android.tools.build:gradle:3.1.0'
Sometimes you need to change name of project manually(look at AndroidStudioProjects folder) that you opened lastly.
After changing name, android studio will show all projects,
open one of them,
in file menu,
click open button,
then open your desire project (or change its name to its previous name)
change build:gradle plugin to:
classpath 'com.android.tools.build:gradle:3.3.2'
(in app gradle file)
I made sure that my Gradle version was compatible with my android gradle plug in. In my case I was using Gradle 6.0.1 and when I changed my android gradle plug in to version 3.5.3 the problem went away.
Project Structure----->> Project ------>> Android Gradle plug in version 3.5.3.
[https://docs.gradle.org/6.0.1/release-notes.html
[Java 14 and later versions are not yet supported.
Compatibility Notes
A Java version between 8 and 13 is required to execute Gradle.
Java 6 and 7 can still be used for compilation and forked test execution. Just like Gradle 5.x, any supported version of Java can be used for compile or test.
This version of Gradle is tested with
-------->>>>>>>>Android Gradle Plugin 3.4, 3.5 and 3.6
Kotlin 1.3.21 through 1.3.50
Other versions may or may not work.]]]]
I hope this helps

ARToolKit ARSimpleProj Error

When I open the ARSimpleProj in Android Studio and try to update the gradle version I get this message:
Failed to update the version of the Android Gradle plugin.
Please click 'OK' to perform a textual search and then update the build files manually.
After this, I'm getting this error:
Error:(58, 0) Gradle DSL method not found: 'android()'
Possible causes:
* The project 'ARSimpleProj' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Fix plugin version and sync project
* The project 'ARSimpleProj' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
* The build file may be missing a Gradle plugin. Apply Gradle plugin.
I tried removing the android->buildToolsVersion and dependencies tag from the top-level, build.gradle file (as indicated in the AS_Migration document) but still it doesn't work.
I finally make it work. When opening the project on the Android Studio, I select "Remind me later" to the Android Gradle Plugin Update recommendation. After this, I could execute and install the application on my cell phone.
Make sure you are using JDK 1.7 in Project Structure. I had problems when using the JDK 1.8 with ARToolkit for Android.

Resources