当第一次运行“gradlew build”时,Proguard找不到引用类
问题描述:
我正在使用gradle构建我的android项目并遇到了一个相当奇怪的问题。当第一次运行“gradlew build”时,Proguard找不到引用类
当我第一次运行“gradlew build”时,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
....
我使用的是0.7的gradle。而我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:[email protected]'
}
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的bug?
从路径使用gradle时,我有同样的问题。第一次构建失败,第二次没事。 所以:如果按顺序执行 “gradle这个干净assembleDebug” “gradle这个干净的构建” 正常工作:( – Harri
听起来Proguard的任务运行太早,由* *以前建造调用生成的类工作 –
。你可以添加一些细节......你使用哪个版本的Gradle插件?lib是否有自己的build.gradle?PullToRefresh是一个源文件还是一个库jar?我似乎无法重现该问题。 –