所以我试图使用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'.
答案 0 :(得分:6)
您无法通过
导入ViewPagerIndicatorcompile 'com.viewpagerindicator:library:2.4.0'
因为Maven工件只是Java库的一个jar,但是VPI依赖于jar中没有的Android资源。
具有AAR打包的Maven工件确实具有资源并且可以工作,但VPI不是这样打包的。它有apklib包装,但Android Gradle插件不支持。
您需要下载源代码并将其设置为android-library模块。
您并未具体说明您正在运行的Android Studio版本,但我愿意打赌您导入的问题不起作用的原因是您的运行时间早于0.4.3 ;从那时起,该区域就已经修复了错误。
答案 1 :(得分:4)
您可以使用this instruction导入AAR:
在build.gradle中包含http://dl.bintray.com/populov/maven作为存储库 priorior 到mavenCentral:
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
像往常一样在依赖项中使用:
dependencies {
compile 'com.viewpagerindicator:library:2.4.1@aar'
}
答案 2 :(得分:3)
如果您在repositories
标记中定义allprojects
,则只需添加@ serge的答案,您也需要在其中添加。{
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
答案 3 :(得分:2)
我用
compile 'com.mcxiaoke.viewpagerindicator:library:2.4.1@aar'
这对我有用。
确保重新同步gradle并重建项目
答案 4 :(得分:0)
我的root build.gradle是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
jcenter()
}
}
,依赖是:compile'com.viewpagerindicator:library:2.4.1@aar'
它的作品就像炸弹一样: - )