我正在使用gradle构建我的android项目并遇到了一个相当奇怪的问题。
当我第一次运行“gradlew build”时,由于proguard无法找到引用的类,构建将会中断。但是,当我再次运行“gradlew build”时,build可以顺利完成。
D:\project\abs-demo>gradlew clean
D:\project\abs-demo>gradlew build // first time, fail
D:\project\abs-demo>gradlew build // second time, succeed
错误消息如下:
Warning: com.actionbarsherlock.sample.demos.ActionItems: can't find superclass or interface com.actionbarsherlock.app.SherlockActivity
Warning: com.actionbarsherlock.sample.demos.ActionModes: can't find superclass or interface com.actionbarsherlock.app.SherlockActivity
Warning: com.actionbarsherlock.sample.demos.ActionModes$AnActionModeOfEpicProportions: can't find superclass or interface com.actionbarsherlock.view.ActionMode$Callback
Warning: com.actionbarsherlock.sample.demos.ActionModesNoActionBar: can't find superclass or interface com.actionbarsherlock.app.SherlockActivity
Warning: com.actionbarsherlock.sample.demos.ActionModesNoActionBar$AnActionModeOfEpicProportions: can't find superclass or interface com.actionbarsherlock.view.ActionMode$Callback
Warning: com.actionbarsherlock.sample.demos.ActionProviders: can't find superclass or interface com.actionbarsherlock.app.SherlockActivity
Warning: com.actionbarsherlock.sample.demos.ActionProviders$SettingsActionProvider: can't find superclass or interface com.actionbarsherlock.view.ActionProvider
....
我正在使用gradle 0.7。还有我的build.gralde:
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile "com.android.support:support-v4:18.0.+"
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
}
android {
compileSdkVersion 19
buildToolsVersion "18.0.0"
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile 'proguard-project.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
我上传了my project here。
我做错了吗?或者这是一个gradle的错误?