Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
784 views
in Technique[技术] by (71.8m points)

ubuntu - Android Studio, Gradle Errors. Content not allowed in Prolog

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()
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...