3

我正在为我的应用程序使用几个库,包括Jake Wharton 的 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 来构建。

4

2 回答 2

2

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

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

于 2013-06-19T08:45:56.477 回答
-1

我提交了一个可能相关的错误。 https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=56882

修复是转到设置,编译器并取消选中使用外部构建。

于 2013-06-21T19:34:36.827 回答