Android ViewPager Indicator 不适用于我的 gradle build设置

标签 android gradle

我正在为我的应用程序使用多个库,包括 Jake Wharton's VPI

这是我的 build.gradle 文件:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':SlidingMenu:library')
    compile project(':Android-ViewPagerIndicator:library')
    compile project(':aFileChooser:aFileChooser')
    compile project(':Crouton:library')
    compile project(':ActionBarSherlock:actionbarsherlock')
    compile project(':ListViewAnimations:library')
    compile project(':Android-Universal-Image-Loader:library')
    compile project(':drag-sort-listview:library')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    sourceSets {
        main {
            manifest.srcFile 'MyMine/AndroidManifest.xml'
            java.srcDirs = ['MyMine/src']
            resources.srcDirs = ['MyMine/src']
            aidl.srcDirs = ['MyMine/src']
            renderscript.srcDirs = ['MyMine/src']
            res.srcDirs = ['MyMine/res']
            assets.srcDirs = ['MyMine/assets']
        }

        instrumentTest.setRoot('tests')
    }
}

settings.gradle:

include ':ActionBarSherlock:actionbarsherlock'
include ':ListViewAnimations:library'
include ':drag-sort-listview:library'
include ':Android-ViewPagerIndicator:library'
include ':Crouton:library'
include ':Android-Universal-Image-Loader:library'
include ':aFileChooser:aFileChooser'
include ':SlidingMenu:library'

这是 ./gradlew build 输出:

[...]
:prepareDebugDependencies
:compileDebugAidl
:generateDebugBuildConfig
:mergeDebugAssets
:compileDebugRenderscript
:mergeDebugResources
:processDebugManifest
:processDebugResources
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:76: error: Error: No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:75: error: Error: No resource found that matches the given name: attr 'vpiTitlePageIndicatorStyle'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.TabPageIndicator'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:81: error: Error: No resource found that matches the given name: attr 'footerColor'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:83: error: Error: No resource found that matches the given name: attr 'footerIndicatorHeight'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:84: error: Error: No resource found that matches the given name: attr 'footerIndicatorStyle'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:82: error: Error: No resource found that matches the given name: attr 'footerLineHeight'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:87: error: Error: No resource found that matches the given name: attr 'selectedBold'.
/Users/bicou/AndroidStudioProjects/MyMine/build/res/all/debug/values-v11/values.xml:86: error: Error: No resource found that matches the given name: attr 'selectedColor'.
:processDebugResources FAILED

如您所见,它只是与 VPI 相关的内容。但它们确实存在:

$ grep vpiTabPageIndicatorStyle Android-ViewPagerIndicator/library/res/values/*
Android-ViewPagerIndicator/library/res/values/vpi__attrs.xml:        <attr name="vpiTabPageIndicatorStyle" format="reference"/>
Android-ViewPagerIndicator/library/res/values/vpi__styles.xml:        <item name="vpiTabPageIndicatorStyle">@style/Widget.TabPageIndicator</item>

这是我的 values-v11/themes.xml 文件:(已删除无用部分)

<style name="MyMineTheme.VPI" parent="MyMineTheme">
    <item name="vpiTitlePageIndicatorStyle">@style/MyMineTitlePageIndicator</item>
    <item name="vpiTabPageIndicatorStyle">@style/MyMineTabPageIndicator</item>
</style>

怎么了?我已经运行了 ./gradlew clean && ./gradlew build

还有一点很有趣:我在使用 Eclipse 的时候遇到这个问题已经有几个星期了,为了编译应用程序,我必须运行 Project> Clean> All 并重新构建。现在我切换到 Android Studio,它仍然可以工作。但是 Studio(还)没有使用 Gradle 进行构建。

最佳答案

问题似乎是您使用的库具有相同的父文件夹名称(通常为“库”)。您需要区分它们,因此要么重命名它,要么将 archivesBaseName = 'something' 放入库的 build.gradle 中。

可以找到基于此的答案 adt google group

关于Android ViewPager Indicator 不适用于我的 gradle build设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17018254/

相关文章:

android - 使用 SpannableString[/Builder] 和富文本

android - Gradle 项目刷新失败,导致 http ://downloads/. ../gradle-2.4.1

intellij-idea - Gradle idea NPE修改ipr文件

java - 如何在 aar 包中的 android 库模块中包含 google-play-services 库作为可选

java - Spring API : the program is not finding the pat into the controller

Android 项目编译,但 Android Studio 无法识别 Maven 依赖项

gradle - 从压缩的 Artifactory 神器下载单个文件

android - 如何在 ScrollView android中的屏幕底部对齐textview

android - 更改默认搜索栏颜色

java - 为什么图像质量下降?