我是Android,Android Studio,Butterknife和Gradle构建系统的新手。但是,我对Java或一般的编程并不陌生。
我正在尝试使用JDK 1.8和Butterknife版本8.1.0构建Android应用程序,但是Gradle构建一直失败,并说:
错误:在任务':app:compileDebugJavaWithJack'上找不到属性'options'。
注意:在我尝试添加Butterknife之前,我的项目与JDK 1.8完美配合(“即时运行”功能除外)。
我已经对此进行了一些研究,并仔细阅读了以下页面/文章,但无法获得关于Butterknife 8.1.0是否与JDK 8兼容的问题的明确答案:
真的有用吗?如果是,我需要怎么做才能使其正常工作?
以下是我的项目设置的详细信息,以及Gradle构建文件中的摘要。我很乐意提供可能需要的任何其他详细信息/文件。
版本详细信息:
build.gradle(项目级别)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// jcenter()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(模块级别)
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "sounakray.popularmovies"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.jakewharton:butterknife:8.1.0'
apt 'com.jakewharton:butterknife-compiler:8.1.0'
}
通过遵循Jake的答案,我可以通过在两个build.gradle文件中进行以下更改来使Butterknife 8.1.0与AS 2.1.2中的JDK 8一起使用:
build.gradle(项目级别)
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha5'
}
build.gradle(模块级别)
apply plugin: 'com.android.application'
//apply plugin: 'android-apt'
...
dependencies {
...
compile 'com.jakewharton:butterknife:8.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
}
如果使用杰克:
annotationProcessor
的依赖关系(而不是apt
)。我相信您必须使用Android Gradle插件的2.2.0版本,而不是2.1.x(当前最新版本是2.2.0-alpha5)。
黄油刀文档将在下一个版本(8.2.0)中进行更新,以包含此信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句