Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content is not allowed in prolog during Gradle build

I tried Different methods but the problem did not solved, I even reinstalled android studio but still getting same issue:

[Fatal Error] annotations-26.1.1.pom:2:1: Content is not allowed in prolog.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'myapp'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools:annotations:26.1.1.
     Required by:
         project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.databinding:compilerCommon:3.1.1
      > Could not resolve com.android.tools:annotations:26.1.1.
         > Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.1.1/annotations-26.1.1.pom
            > Content is not allowed in prolog.
   > Could not resolve com.android.tools:annotations:26.1.1.
     Required by:
         project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.build:builder-model:3.1.1
         project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools:common:26.1.1
         project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.analytics-library:shared:26.1.1
         project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.analytics-library:tracker:26.1.1
         project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools:sdklib:26.1.1 > com.android.tools.layoutlib:layoutlib-api:26.1.1
      > Could not resolve com.android.tools:annotations:26.1.1.
         > Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.1.1/annotations-26.1.1.pom
            > Content is not allowed in prolog.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 34s

Content is not allowed in prolog.

app\build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.kakarot.myapp"
        minSdkVersion 24
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

Project (build.gradle)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I added the app module build.gradle and project build.gradle.

like image 859
Ahtisham Ilyas Avatar asked Apr 13 '18 21:04

Ahtisham Ilyas


2 Answers

Worked on Android Studio 3.0.1.

Close android studio if it is open already and then delete all the contents of these directories.

C:\Users\USER_NAME\.gradle\caches
C:\Users\USER_NAME\.android\build-cache
C:\Users\USER_NAME\.android\cache

Start Android Studio and and it will probably work. It may take a little bit time to load for the first time.

like image 84
Bertram Gilfoyle Avatar answered Nov 18 '22 08:11

Bertram Gilfoyle


After a lot of struggle and searching online, i finally solve the problem.

I deleted all the cached folders in gradle and when i build my new project. It work like magic. Thanks @ישו אוהב אותך for reply and trying to help me.

like image 27
Ahtisham Ilyas Avatar answered Nov 18 '22 06:11

Ahtisham Ilyas