Android Gradle生成期间prolog中不允许包含内容
我尝试了不同的方法,但问题没有解决,我甚至重新安装了android studio,但仍然遇到相同的问题:Android Gradle生成期间prolog中不允许包含内容,android,android-gradle-plugin,Android,Android Gradle Plugin,我尝试了不同的方法,但问题没有解决,我甚至重新安装了android studio,但仍然遇到相同的问题: [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'. > C
[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
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'
}
项目(build.gradle) //顶级生成文件,您可以在其中添加所有子项目/模块通用的配置选项
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
}
我添加了app module build.gradle和project build.gradle。经过大量的努力和在线搜索,我终于解决了这个问题 当我构建新项目时,我删除了gradle中的所有缓存文件夹。它像魔术一样工作。
感谢的回复和帮助。在Android Studio 3.0.1上工作。 关闭android studio(如果它已经打开),然后删除这些目录的所有内容
C:\Users\USER_NAME\.gradle\caches
C:\Users\USER_NAME\.android\build-cache
C:\Users\USER_NAME\.android\cache
启动Android Studio,它可能会工作。第一次加载可能需要一点时间。您的
build.gradle
有问题。请附上您的项目build.gradle
和应用程序模块build.gradle
谢谢您的回复,我已经附上了您要求的文件。我已经检查并运行了一个项目,该项目将与您的build.gradle
一模一样,没有问题。你试过清理和重建项目吗?或者您可能支持代理?我没有使用代理,并且重建和清理项目无法从顶部菜单工作,因此我使用“/gradlew clean”命令清理项目,但仍然收到相同的错误