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