我是
Android,
Android Studio,Butterknife和Gradle构建系统的新手.但是,我不是Java的新手,也不是一般的编程.
我正在尝试使用JDK 1.8和Butterknife版本8.1.0构建一个Android应用程序,但Gradle构建仍然失败,说:
Error:Could not find property ‘options’ on task
‘:app:compileDebugJavaWithJack’.
注意:我的项目与JDK 1.8完全正常(除了“即时运行”功能),直到我尝试添加Butterknife.
我已经对此进行了一些研究,并浏览了以下几页/文章,但无法明确回答Butterknife 8.1.0是否与JDK 8协同工作的问题:
它有用吗?如果是,我需要做些什么才能使其正常工作?
以下是我的项目设置的详细信息,以及Gradle构建文件中的代码段.
我很乐意提供可能需要的任何其他详细信息/文件.
版本细节:
> JDK 1.8.0_92(64位)
> Android Studio 2.1.2
> Gradle 2.1.2
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’s的答案,我可以通过在两个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'
}
本文为Android新手指南,讲述了如何在Android Studio 2.1.2和Gradle 2.1.2环境下,配合JDK1.8和Butterknife 8.1.0实现项目编译,重点介绍了解决`Jack编译错误`的方法和所需配置步骤。

被折叠的 条评论
为什么被折叠?



