cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected

Viewed 41173

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.

6 Answers

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.3'

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.0.2-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

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.

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

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

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)

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
Related