95

I am facing this issue many times when i download project from github i am using new Android studio(bumble bee) please help me if any body knows

https://github.com/fjbatresv/arcore_solar_system.git (this is the project which i am downloading in bumble bee)

There are not any gradle issue

actually i have tried many solutions from stack over flow but i am getting solutions for gradle but it is not an gradle related error.

Anil Dhiman
  • 1,011
  • 1
  • 4
  • 6
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 30 '22 at 12:31

6 Answers6

114

Upgrade your com.android.tools.build:gradle in your build.gradle file to the latest version

e.g.

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

And upgrade your gradle-wrapper.properties to the latest version i.e.

#Tue Apr 12 23:39:17 AEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Optionally, you can upgrade it using Project-Structure UI

enter image description here

letsintegreat
  • 3,328
  • 4
  • 18
  • 39
Elye
  • 53,639
  • 54
  • 212
  • 474
  • 2
    It also needs JDK 11 or above to be used. So please update that as well if you apply the above solution. – Harpreet Nov 01 '22 at 09:54
  • 1
    To update the project to compile with Java 11, goto Android Studio ➔ File ➔ Project Structure ➔ SDK Location ➔ click Gradle Settings ➔ Gradle JDK = 11 – Mr-IDE Dec 06 '22 at 11:02
  • 1
    What if you can't or don't want to update? It's pretty concerning how "just update to the latest" has become a commonly recommended (and readily accepted) "fix" for things that should have never been broken in the first place. In this case, the root cause was very likely a mistake, as described by @dont-panic below, and can be resolved without changing any versions. – friederbluemle Jan 14 '23 at 05:26
16

I was facing same issue and solved it with following changes

In File -> Project Structure, set Android Gradle Plugin Version 7.0.3 And Gradle Version 7.0.2.

  • 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 May 16 '22 at 02:54
10

Upgrade your Android Gradle plugin version to 4.0.1 or higher in the project build.gradle file

buildscript {
    dependencies {
        classpath("com.android.tools.build:gradle:4.0.1")
        ...
    }
}

Upgrade the Gradle version to 6.5 or higher in the gradle-wrapper.properties file.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
5

For me I resolved by

Go to File > Project Structure > SDK Location > Gradle Settings.

Check there Gradle JDK, try changing it and then sync again.

solution

Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
  • 2
    Note: that to find the gradle settings there is a text link "JDK Location was moved to "Gradle Settings" You can see part of this text link in the screen shot just behind the pop-up – dcarl661 Sep 14 '22 at 23:09
5

I also faced similar issue. cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected. Finally i was able to fix this issue, by Go To File>>Settings>>Build, Execution, Deployment>Build Tools And I am enable "Reload project after changes in the build scripts">Any changes after this Appeared new Error "Add Google maven repository" I add Google maven repository to build.gradle and project worked without any errors enter image description here

3

I solved the problem after digging into the source code and some experiments.

Android SDK configuration file ~/Library/Android/sdk/platforms/android-32/package.xml has an extra tag named base-extension compared to the same file of other API levels. Removing this tag solves the problem.

Delete downloaded Android API 32 SDK Platform from SDK Manager (Tools → SDK Manager) also solves the problem (you can redownload after deletion). Maybe the Android studio team noticed the problem, redownloading API 32 platform files, the base-extension tag disappeared from the API 32 package.xml

the extra tag in android-32/package.xml (after format the file)

↑ the extra tag in android-32/package.xml (after formatting the file)

don't panic
  • 6,033
  • 2
  • 17
  • 15