吐嘈:麻蛋,我电脑CSDN又抽风了~~~
最近不知道在忙什么,好久没更新了,发现也没什么想分享的。还是要坚持写Blog!!
今天看了一个别人的项目,用的JDK8,不知道什么原因,一直报我错,但我电脑配置是正常的啊 - 我之前有工程用了JDK8 - 所以这里记录一下JDK8的使用方法笔记,解惑自己猜疑
如标题,我只是想使用JDK8,新建一个android studio
工程,配置如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0-alpha5' classpath 'me.tatarka:gradle-retrolambda:3.2.5'
} }
allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } }
task clean(type: Delete) { delete rootProject.buildDir }
|
添加classpath 'me.tatarka:gradle-retrolambda:3.2.5'
和maven { url "https://jitpack.io" }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| apply plugin: 'com.android.application' apply plugin: 'me.tatarka.retrolambda'
android { compileSdkVersion 23 buildToolsVersion "23.0.3"
defaultConfig { applicationId "com.xuie.jdk8_demo" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
}
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.android.support:design:23.3.0' }
|
添加
apply plugin: 'me.tatarka.retrolambda'
和
1 2 3 4
| compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
|
1 2
| fab.setOnClickListener(view->Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show());
|
上张截图,原先的写法多余部分已经为成为提示无意义