我正在使用gradle构建我的android项目,并遇到了一个非常奇怪的问题。
第一次运行“gradlew构建”时,由于proguard找不到引用的类,构建将中断。但是,当我再次运行“gradlew构建”时,构建可以成功完成。
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的错误?
最佳答案
这是Android Gradle插件版本0.7.0和0.7.1中的问题:issue 63944和issue 64039。