我的Android应用即将完成,但Android工作室现在似乎无法使用。到处都是红线,并显示消息“Gradle项目同步已完成并出现一些错误”。我用谷歌搜索过,我看过youtube视频,但他们使用的工作室版本比我的版本旧,用户界面也不同。
我尝试过来自SO和互联网的各种解决方案,包括构建项目,从本地gradle分发更改为默认包装器;再回头;取消选中android sdk mangager上的所有框并重新检查它们,更改类路径以使t与设置中的匹配;改回来。一切都让这更糟。
现在,当按下运行时,它会向我显示一个编辑配置窗口,其中显示消息“Gradle项目同步失败。请修复您的项目并重试。”
老实说,我只是使用android-studio编写应用程序。我不知道它是如何工作的或幕后发生的事情。我在这里有点过头了。
build.gradle code:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序/的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.lp1"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.+'
compile 'com.android.support:design:24.2.0'
}
编辑:更改了appcompat-v7:24. +'到appcompat-v7:24.2.0'
现在,日志显示为:Information:Gradle tasks [:app:assembleDebug]
[Fatal Error] appcompat-v7-24.2.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] recyclerview-v7-24.2.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] support-annotations-24.2.0.pom:2:1: Content is not allowed in prolog.
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.android.support:appcompat-v7:24.2.0.
Required by:
Lp1:app:unspecified
Lp1:app:unspecified > com.android.support:design:24.2.0
> Could not resolve com.android.support:appcompat-v7:24.2.0.
> Could not parse POM /home/david/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/24.2.0/appcompat-v7-24.2.0.pom
> Content is not allowed in prolog.
> Could not resolve com.android.support:recyclerview-v7:24.2.0.
Required by:
Lp1:app:unspecified > com.android.support:design:24.2.0
> Could not resolve com.android.support:recyclerview-v7:24.2.0.
> Could not parse POM /home/david/Android/Sdk/extras/android/m2repository/com/android/support/recyclerview-v7/24.2.0/recyclerview-v7-24.2.0.pom
> Content is not allowed in prolog.
> Could not resolve com.android.support:support-annotations:24.2.0.
Required by:
Lp1:app:unspecified > com.android.support:design:24.2.0 > com.android.support:support-v4:24.2.0 > com.android.support:support-compat:24.2.0
> Could not resolve com.android.support:support-annotations:24.2.0.
> Could not parse POM /home/david/Android/Sdk/extras/android/m2repository/com/android/support/support-annotations/24.2.0/support-annotations-24.2.0.pom
> Content is not allowed in prolog.
Information:BUILD FAILED
Information:Total time: 3.244 secs
Information:1 error
Information:0 warnings
Information:See complete output in console