我接手了一个使用appcompat-v7:20.0.0的项目。
我无法构建该项目,因为似乎gradle在同步/构建时没有包含appcompat库。
我的build.gradle文件中的依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.google.android.gms:play-services:+'
}
同时,该项目未引入任何 Google Play 服务,但引入了 Nine Old Androids(我尝试引入不同的库,似乎所有从 JCenter 下载的库都会被引入)。如下截图所示:
![external libraries](https://istack.dev59.com/AaDhp.webp)
Gradle 插件版本为 1.0.0,并且同步过程中没有出现任何问题。是否有已知的解决此类问题的方法? 编辑 1:
Android 支持存储库
Android 支持库
Google Play 服务
均已安装。然而,新创建的项目也可正常使用。
编辑 2:
./gradlew build
输出如下:Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/stephan/Library/Android/sdk/build-tools/20.0.0/aapt package -f --no-crunch -I /Users/stephan/Library/Android/sdk/platforms/android-21/android.jar -M /Users/project-path/build/intermediates/manifests/full/flavor/beta/AndroidManifest.xml -S /Users/project-path/build/intermediates/res/flavor/beta -A /Users/project-path/build/intermediates/assets/flavor/beta -m -J /Users/project-path/build/generated/source/r/flavor/beta -F /Users/project-path/build/intermediates/res/resources-flavor-beta.ap_ --debug-mode --custom-package de.my.project -0 apk --output-text-symbols /Users/project-path/build/intermediates/symbols/flavor/beta
Error Code:
1
Output:
/Users/project-path/build/intermediates/res/flavor/beta/values/values.xml:2127: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.Base.Spinner'.
/Users/project-path/build/intermediates/res/flavor/beta/values-v16/values.xml:89: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.Base.Spinner'.
我还检查了
Widget.AppCompat.Light.Base.Spinner
是appcompat-v7 20.0.0
中的values.xml
的一部分。
以下是SDK版本:
compileSdkVersion "Google Inc.:Google APIs:21"
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 17
}
编辑3:
项目根目录下的build.gradle文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
应用程序构建.gradle
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.google.android.gms:play-services:+'
}
android {
compileSdkVersion "Google Inc.:Google APIs:21"
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 17
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
signingConfigs {
conf1 {
storeFile file("path")
storePassword ""
keyAlias ""
keyPassword ""
}
debug {
storeFile file("path")
storePassword ""
keyAlias ""
keyPassword ""
}
}
buildTypes {
debug {
zipAlignEnabled true
minifyEnabled false
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile 'proguard-project.txt'
signingConfig signingConfigs.debug
}
release {
zipAlignEnabled true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
proguardFiles 'proguard-rules.pro'
}
beta {
initWith debug
signingConfig signingConfigs.debug
}
}
productFlavors {
flavor1 {
applicationId "de.package"
versionCode 1
versionName "1.0"
signingConfig signingConfigs.conf1
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
Widget.AppCompat.Light.Base.Spinner
。 - Stephanbuild.gradle
的属性。我还刚刚检查了代码库并尝试了一个不使用Android Studio的构建。这绝对是一个Gradle问题。 - Stephangradlew --gui
构建失败了? - k3b