所以我正在尝试使用 actionbarsherlock 和 viewpagerindicator,但出于某种原因,viewpagerindicator 库由于某种原因没有被导入。有人知道吗?
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.viewpagerindicator:library:2.4.0'
}
dependencies {
compile project(':libraries:facebook')
}
此导入错误“无法解析符号 viewpageindicator
import com.viewpagerindicator.TabPageIndicator;
这些是我的“消息 gradle 任务”
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\android-sdk\build-tools\19.0.1\aapt.exe package -f --no-crunch -I C:\android-sdk\platforms\android-19\android.jar -M C:\myAppName\app\build\manifests\debug\AndroidManifest.xml -S C:\myAppName\app\build\res\all\debug -A C:\myAppName\app\build\assets\debug -m -J C:\myAppName\app\build\source\r\debug -F C:\myAppName\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.myAppName.app --output-text-symbols C:\myAppName\app\build\symbols\debug
Error Code:
1
Output:
C:\myAppName\app\build\res\all\debug\values\values.xml:911: error: Error: No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
C:\myAppName\app\build\res\all\debug\values\values.xml:914: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
C:\myAppName\app\build\res\all\debug\values\values.xml:934: error: Error: No resource found that matches the given name: attr 'fadeDelay'.
C:\myAppName\app\build\res\all\debug\values\values.xml:933: error: Error: No resource found that matches the given name: attr 'fadeLength'.
C:\myAppName\app\build\res\all\debug\values\values.xml:931: error: Error: No resource found that matches the given name: attr 'selectedColor'.
C:\myAppName\app\src\main\res\values\styles.xml
No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
No resource found that matches the given name: attr 'fadeDelay'.
No resource found that matches the given name: attr 'fadeLength'.
No resource found that matches the given name: attr 'selectedColor'.
最佳答案
不能通过
导入ViewPagerIndicatorcompile 'com.viewpagerindicator:library:2.4.0'
因为 Maven Artifact 只是 Java 库的一个 jar,但 VPI 依赖于 jar 中没有的 Android 资源。
具有 AAR 打包的 Maven Artifact 确实有资源并且可以工作,但 VPI 不是这样打包的。它有 apklib 打包,但 Android Gradle 插件不支持。
您需要下载源代码并将其设置为 android-library 模块。
你没有具体说明你运行的是什么版本的 Android Studio,但我敢打赌你的导入不起作用的问题是因为你运行的是早于 0.4.3 的版本;从那时起,该区域的错误已得到修复。
关于android - Gradle - 无法使用 gradle 依赖项在 Android Studio 中导入 viewpagerindicator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21716526/