kaushalyap
kaushalyap

Reputation: 13597

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

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.

Upvotes: 11

Views: 13191

Answers (5)

Lakshman Jodhawat
Lakshman Jodhawat

Reputation: 447

Update Gradle in Android Studio to the latest version.

Upvotes: 0

Rohit Mandiwal
Rohit Mandiwal

Reputation: 10462

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

Upvotes: 1

Kleiren
Kleiren

Reputation: 324

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.

Upvotes: 15

kaushalyap
kaushalyap

Reputation: 13597

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' }

Upvotes: 2

tomoima525
tomoima525

Reputation: 846

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

Upvotes: 2

Related Questions