所以我正在尝试使用动作栏夏洛克和视图页面指示器,由于某种原因,视图页面指示器库由于某种原因没有被导入。有人知道吗?
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')
}
此导入错误"无法解析符号视图页面指示器
import com.viewpagerindicator.TabPageIndicator;
这些是我的"消息分级任务"
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:android-sdkbuild-tools19.0.1aapt.exe package -f --no-crunch -I C:android-sdkplatformsandroid-19android.jar -M C:myAppNameappbuildmanifestsdebugAndroidManifest.xml -S C:myAppNameappbuildresalldebug -A C:myAppNameappbuildassetsdebug -m -J C:myAppNameappbuildsourcerdebug -F C:myAppNameappbuildlibsapp-debug.ap_ --debug-mode --custom-package com.myAppName.app --output-text-symbols C:myAppNameappbuildsymbolsdebug
Error Code:
1
Output:
C:myAppNameappbuildresalldebugvaluesvalues.xml:911: error: Error: No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
C:myAppNameappbuildresalldebugvaluesvalues.xml:914: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
C:myAppNameappbuildresalldebugvaluesvalues.xml:934: error: Error: No resource found that matches the given name: attr 'fadeDelay'.
C:myAppNameappbuildresalldebugvaluesvalues.xml:933: error: Error: No resource found that matches the given name: attr 'fadeLength'.
C:myAppNameappbuildresalldebugvaluesvalues.xml:931: error: Error: No resource found that matches the given name: attr 'selectedColor'.
C:myAppNameappsrcmainresvaluesstyles.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'.
您无法通过以下方式导入 ViewPagerIndicator。
compile 'com.viewpagerindicator:library:2.4.0'
因为Maven工件只是Java库的一个罐子,但VPI依赖于不在罐子里的Android资源。
具有 AAR 打包的 Maven 工件确实有资源并且可以工作,但 VPI 不是这样打包的。它有apklib打包,但Android Gradle插件不支持。
您需要下载源代码并将其设置为安卓库模块。
您没有具体说明您正在运行的Android Studio版本,但我敢打赌,导入不起作用的问题是由于您运行的是低于0.4.3的内容;从那时起,该领域的错误已得到修复。
您可以使用以下说明导入 AAR:
在你的build.gradle中,包括 http://dl.bintray.com/populov/maven 作为mavenCentral的存储库:
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
像往常一样在依赖项中使用:
dependencies {
compile 'com.viewpagerindicator:library:2.4.1@aar'
}
为了添加到@serge的答案中,如果您在标签中定义了repositories
allprojects
您也需要将其添加到那里。
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
我使用
compile 'com.mcxiaoke.viewpagerindicator:library:2.4.1@aar'
这对我来说是工作。
并确保重新同步gradle并重新构建项目
我的根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()
}
}
依赖关系是:编译'com.viewpagerindicator:library:2.4.1@aar'
它的作品像炸弹:-)