android studio 2.2 jdk1.8,Butterknife 8.1.0在Android Studio 2.1.2中不能与JDK 1.8一起使用

本文为Android新手指南,讲述了如何在Android Studio 2.1.2和Gradle 2.1.2环境下,配合JDK1.8和Butterknife 8.1.0实现项目编译,重点介绍了解决`Jack编译错误`的方法和所需配置步骤。

我是

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'

}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值