11

I've been using Android Studio with Ubuntu 13.10 no problem. I decided to update to 14.04 and now I can't get Android Studio working. Gradle fails to build and keeps saying Error: Content not allowed in Prolog. All I'm doing is creating a new project from scratch.

  1. Ubuntu 14.04 was installed from a freshly wiped partition
  2. Using Android Studio v5.7, though I also tried v4.6
  3. I installed Oracle JDK and set the $JAVA_HOME path accordingly
  4. I've apt-get installed gradle
  5. I've ensured build.gradle has:

    dependencies { classpath 'com.android.tools.build:gradle:0.9.+' }

  6. I've tried gradle build clean. It errors out too.

  7. I've tried clean/rebuild project within Android Studio. Errors out.

Error report:

[Fatal Error] oss-parent-7.pom:2:1: Content is not allowed in prolog.
[Fatal Error] proguard-base-4.10.pom:2:1: Content is not allowed in prolog.
[Fatal Error] commons-compress-1.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] oss-parent-7.pom:2:1: Content is not allowed in prolog.
[Fatal Error] httpcore-4.1.pom:2:1: Content is not allowed in prolog.
[Fatal Error] commons-logging-1.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 'ArrayAdapterEx'.
> Could not resolve all dependencies for configuration ':classpath'.

Could not resolve com.squareup:javawriter:2.2.1. Required by: :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 Could not parse POM http://repo1.maven.org/maven2/com/squareup/javawriter/2.2.1/javawriter-2.2.1.pom Could not resolve org.sonatype.oss:oss-parent:7. Could not parse POM http://repo1.maven.org/maven2/org/sonatype/oss/oss-parent/7/oss-parent-7.pom Content is not allowed in prolog. Could not resolve net.sf.proguard:proguard-base:4.10. Required by: :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > net.sf.proguard:proguard-gradle:4.10 Could not parse POM http://repo1.maven.org/maven2/net/sf/proguard/proguard-base/4.10/proguard-base-4.10.pom Content is not allowed in prolog. Could not resolve org.apache.commons:commons-compress:1.0. Required by: :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 > com.android.tools:sdklib:22.7.2 Could not parse POM http://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.0/commons-compress-1.0.pom Content is not allowed in prolog. Could not resolve com.google.guava:guava:15.0. Required by: :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 > com.android.tools:common:22.7.2 :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.lint:lint:22.7.2 > com.android.tools.lint:lint-checks:22.7.2 > com.android.tools.lint:lint-api:22.7.2 > com.android.tools.external.lombok:lombok-ast:0.2.2 Could not parse POM http://repo1.maven.org/maven2/com/google/guava/guava/15.0/guava-15.0.pom Could not resolve com.google.guava:guava-parent:15.0. Could not parse POM http://repo1.maven.org/maven2/com/google/guava/guava-parent/15.0/guava-parent-15.0.pom Could not resolve org.sonatype.oss:oss-parent:7. Could not parse POM http://repo1.maven.org/maven2/org/sonatype/oss/oss-parent/7/oss-parent-7.pom Content is not allowed in prolog. Could not resolve org.apache.httpcomponents:httpcore:4.1. Required by: :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 > com.android.tools:sdklib:22.7.2 > org.apache.httpcomponents:httpclient:4.1.1 :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 > com.android.tools:sdklib:22.7.2 > org.apache.httpcomponents:httpmime:4.1 Could not parse POM http://repo1.maven.org/maven2/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.pom Content is not allowed in prolog. Could not resolve commons-logging:commons-logging:1.1.1. Required by: :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 > com.android.tools:sdklib:22.7.2 > org.apache.httpcomponents:httpclient:4.1.1 :ArrayAdapterEx:unspecified > com.android.tools.build:gradle:0.9.2 > com.android.tools.build:builder:0.9.2 > com.android.tools:sdklib:22.7.2 > org.apache.httpcomponents:httpmime:4.1 Could not parse POM http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom Content is not allowed in prolog.

App build.gradle:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
}

Global build.grade:

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

allprojects {
    repositories {
        mavenCentral()
    }
}
Ifrit
  • 6,791
  • 8
  • 50
  • 79
  • That sounds like an XML validation error. If I had to guess, I'd say there's some network error that's preventing your POM files from downloading properly. Either they're corrupt, or maybe it's downloading an error page from a server or proxy or network layer in place of a valid POM. – Scott Barta May 02 '14 at 23:24
  • How would I go about verifying that? – Ifrit May 03 '14 at 00:18
  • Post your build.gradle. – interlude May 07 '14 at 13:30
  • Posted both build.gradle files. – Ifrit May 07 '14 at 23:54
  • You should have a look at one of those POM files it's complaining about in the error message and see what's in there. That might give you some insight into what's going wrong. – Scott Barta May 08 '14 at 00:02
  • You could try clearing your gradle cache: `gradle clean --refresh-dependencies` and delete contents of `~/.gradle/caches`. Might help. – myanimal May 08 '14 at 16:48
  • @myanimal, that didn't solve my issue but gave me a new error message which lead me to solve the problem. Write your comment up as an answer, and I'll accept to give you the bounty. – Ifrit May 09 '14 at 00:40

2 Answers2

19

You could try clearing your gradle cache: gradle clean --refresh-dependencies and delete the contents of ~/.gradle/caches. Should help.

For more details, see https://stackoverflow.com/a/22670684/1243753

Community
  • 1
  • 1
myanimal
  • 3,580
  • 26
  • 26
  • That ended up giving me a new error about failing to create the app plugin. After googling the error, turns out it's a bug with android gradle 0.9.2. Explicitly using 0.9.1 instead of 0.9.+ solved the issue. Thanx a mil! – Ifrit May 09 '14 at 10:48
  • Glad it helped. Updated the answer with the link you provided. – myanimal May 09 '14 at 10:52
  • 1
    @myanimal sorry i am new to android studio, but where do i write this command gradle --refresh-dependencies – Sagar Devanga Jan 02 '15 at 08:31
  • @SagarDevanga you can type the commands in a terminal/command line at the root of your project. The location for the gradle cache is for Linux systems, not sure exactly where it would be on Windows. You could probably also use the gradle wrapper: `./gradlew` or `gradle.bat` – myanimal Jan 02 '15 at 11:51
  • 'gradle clean --refresh-dependencies' Will this command work for flutter project also ? I got error as 'task clean not found in root project' – K Pradeep Kumar Reddy Jun 13 '20 at 13:55
0

I had the same issue. Android Studio was having issues from Desktop.ini files in subfolders of the res directory.

I deleted all the desktop.ini files (which google drive uses) and then it worked.

nalband
  • 81
  • 5