11

I opened my project in Android Studio canary 4, then I decided to open it in stable version 3.5.1 Now I get the following message.

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

I tried followings

  1. deleting .gradle, .idea, gradle/, project.iml
  2. invalidate cache
  3. close and reimport project
  4. changed the agp and Kotlin to previous versions.

Seems I have to stick with 4.0.

4
  • Look in the build.gradle in your project root directory. What do you have for the com.android.tools.build:gradle version number? Commented Nov 2, 2019 at 12:28
  • @CommonsWare I already did it, I updated the question.
    – kaushalyap
    Commented Nov 2, 2019 at 12:30
  • @user158 What do you have for the com.android.tools.build:gradle version number? Commented Nov 2, 2019 at 15:34
  • @GabrieleMariotti it's 3.5.0
    – kaushalyap
    Commented Nov 3, 2019 at 0:41

5 Answers 5

15

I just had this issue. To fix it I only needed to change in my build.gradle from

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

to

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

The latest non 4.x version of the gradle plug-in https://developer.android.com/studio/releases/gradle-plugin

Then, after a gradle sync, everything worked properly. I didn't need to do anything else.

2

I was able to solve this issue by deleting ~./android/build-cache/4.x and ~./android/build-cache/4.x.lock

After removing the file and directory above, re-start the project and check if those show up again under build-cache. If they show up that means com.android.tools.build:gradle:4.x is still applied somewhere in your project. I searched the file from Finder and Android Studio that had 4.x name on it and changed it to 3.5.2

2

Today I was able to fixed the issue, what had happened

I was using buildSrc to declare my dependencies, I had changed the AGP and Kotlin versions in buildSrc, but when opening the project with AS canary, AS have added an extra AGP dependency statement in addition to the existing AGP dependency statement referring buildSrc

ex:

dependencies {
    classpath GradlePlugins.GRADLE
    ...
    classpath 'com.android.tools.build:gradle:4.0.0-alpha06'
}

Removing additionally added AGP dependency fixed the issue.


Other than that remove the following line from repositories blocks in project build.gradle, since it is for a bug fix in AS Canary 4.0

// maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
0
1

in my case, I switched to classpath "com.android.tools.build:gradle:3.6.3" then Clean & Build

0

Update Gradle in Android Studio to the latest version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.