4

While learning android studio from udacity they asked me to download a project; I did so but while I was importing it to android studio I got an error message:

The project uses Gradle 2.10 which is incompatible with Android Studio 2020.3.

Why did I get this error?

miken32
  • 42,008
  • 16
  • 111
  • 154
Rajveer Jhalani
  • 49
  • 1
  • 2
  • 3

5 Answers5

2

If you did not figure this out yet, I am just starting the same project too. I changed the classpath like above. I then found a website to use the latest version of gradle and the plugin. It says "You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or by editing the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file." I did the first one.

Then, I got errors for both build.gradle files in the project and app version. I get this error: Could not find com.android.tools.build:gradle:7.0.3

If you get this error, click the link "Add google Maven repository and sync project". Then you have to click "Do refactor".

Now you come across another error in one of the build.grade files. This stackoverflow link will tell you: Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]

Finally, replace testCompile with testImplementation and then you should get BUILD SUCCESSFUL.

Rebecca Zee
  • 21
  • 1
  • 5
1

The project's Gradle version you're trying to clone is outdated. Change it based on your android studio version.

on your build.gradle(Project) change the version and sync

classpath "com.android.tools.build:gradle:4.1.2"
Patrick
  • 107
  • 7
  • see i am new to android studio so wanted to know do i need the change the gradel version or the android gradel plugin version ???these are there in project structure – Rajveer Jhalani Aug 16 '21 at 09:51
  • i just tried to upgrade the wrapper to 4.8 but now it says - Unable to load class 'javax.xml.bind.annotation.XmlSchema'. ...what should i do ?? – Rajveer Jhalani Aug 16 '21 at 09:53
1

Got the solution :)

In gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

In build.gradle project level:

buildscript {
repositories {
    google()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:7.0.4'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

In build.gradle module level:

Replace all "compile" with "Implementation" and do other suggested version updated and you are done here :)

Hope this works for you, if yes just press that up button :)

0

If not getting any solution, the best you can do is copy the "app" folder of your project(using file explorer) and paste it in a newly created project(should be of same name as of your project), in that way you'll get already synced gradle and newly created version of your app. Because, every important thing in your project is present in its app folder and when you create a new project with same name and copy app folder from your older version of your project, you will have a newer version of your project with all same resources. Note: You can't move through branches and other commits

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '22 at 15:59
0

I saw this issue several times with Android studio. Below trick worked me the best.

  1. Android Studio suggests to upgrade to newer version, please upgrade it and let it sync
  2. Mostly you would see error message again
  3. Now, Go to File -> Invalidate Caches/Restart
  4. It should work now

If it shows same error then I don't know what to do. If it shows different error then repeat from step 1 to 3 for new error.

Hope, it helps some..

Sreenu Yatam
  • 166
  • 4