问题描述
我有我与Android 0.4.0工作室创建了一个简单的Android项目。我用1.9摇篮和摇篮Android插件0.7。昨天我在我的摇篮构建脚本添加杰克沃顿商学院的 ButterKnife库:
I have a simple android project that I created with Android Studio 0.4.0.I use Gradle 1.9 and Gradle Android Plugin 0.7. Yesterday I've added Jake Wharton's ButterKnife library in my gradle build script:
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
// Butterknife
compile 'com.jakewharton:butterknife:4.0.1'
}
当我运行的Android Studio中的应用,构建运行良好,并在我的设备的正确执行。但是,当我尝试(在命令行)摇篮构建
构建失败。下面是部分从我的皮棉报告:
When I run the application from Android Studio, the build runs fine and executes correctly on my devices. But when I try (from the command line) gradle build
the build fails. Here is a part from my lint report:
InvalidPackage: Package not included in Android
/home/yami/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/4.0.1/f43b36925363701633d01adb8e54df7150397a78/butterknife-4.0.1.jar: Invalid package reference in library; not included in Android: javax.annotation.processing. Referenced from butterknife.internal.InjectViewProcessor.
/home/yami/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/4.0.1/f43b36925363701633d01adb8e54df7150397a78/butterknife-4.0.1.jar: Invalid package reference in library; not included in Android: javax.annotation.processing. Referenced from butterknife.internal.InjectViewProcessor.
/home/yami/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/4.0.1/f43b36925363701633d01adb8e54df7150397a78/butterknife-4.0.1.jar: Invalid package reference in library; not included in Android: javax.annotation.processing. Referenced from butterknife.internal.InjectViewProcessor.
/home/yami/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/4.0.1/f43b36925363701633d01adb8e54df7150397a78/butterknife-4.0.1.jar: Invalid package reference in library; not included in Android: javax.annotation.processing. Referenced from butterknife.internal.InjectViewProcessor.
/home/yami/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/4.0.1/f43b36925363701633d01adb8e54df7150397a78/butterknife-4.0.1.jar: Invalid package reference in library; not included in Android: javax.annotation.processing. Referenced from butterknife.internal.InjectViewProcessor.
也许我失去了一些东西,但没有能够在终端模块来构建项目CI的可能性为Android项目。
Maybe I'm missing something, but not to be able to build the project in the terminal blocks the possibility of CI for Android projects.
任何帮助将是巨大的。
推荐答案
是 0.7.0 总会有扩展支持,林特,然而,它并不总是正常工作。 (例如,在butterknife库)
With 0.7.0 there comes extended support for Lint, however, it does not work always properly. (Eg. the butterknife library)
解决办法是禁用中止基础上发现皮棉错误
Solution is to disable aborting build on found lint errors
我把灵感来自于https://android.googlesource.com/platform/tools/base/+/e6a5b9c7c1bca4da402de442315b5ff1ada819c7
(执行:https://android.googlesource.com/platform/tools/base/+/e6a5b9c7c1bca4da402de442315b5ff1ada819c7/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/DefaultAndroidProject.java )
(讨论:https://plus.google.com/+AndroidDevelopers/posts/ersS6fMLxw1 )
android {
// your build config
defaultConfig { ... }
signingConfigs { ... }
compileOptions { ... }
buildTypes { ... }
// This is important, it will run lint checks but won't abort build
lintOptions {
abortOnError false
}
}
如果你需要禁用只是特定的皮棉规则,并保持在构建失败的人,用这个:
/*
* Use only 'disable' or only 'enable', those configurations exclude each other
*/
android {
lintOptions {
// use this line to check all rules except those listed
disable 'RuleToDisable', 'SecondRuleToDisable'
// use this line to check just listed rules
enable 'FirstRuleToCheck', 'LastRuleToCheck'
}
}
这篇关于在皮棉任务摇篮构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!