Android studio支持lamda
https://www.jianshu.com/p/ef6cbf5ade71
方法一:11.25新建的项目
app的build.gradle下面:
android { //只需要这样就行了 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } ... defaultConfig { ... } .... }
我的项目所有:
app build.gradle如下:
apply plugin: 'com.android.application' apply plugin: 'com.alipay.apollo.baseline.config' android { //支持lamda compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } compileSdkVersion 30 buildToolsVersion "30.0.2" defaultConfig { applicationId "com.zhu.mpaas" minSdkVersion 19 // 接入第1步 targetSdkVersion 26 versionCode 1 versionName "1.0" ndk{ abiFilters 'armeabi' } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro','mpProguard.cfg' } } } dependencies { implementation 'androidx.multidex:multidex:2.0.1' implementation platform("com.mpaas.android:$mpaas_artifact:$mpaas_baseline") implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'com.mpaas.android:essential' implementation 'com.mpaas.android:framework' implementation 'com.mpaas.android:configservice' implementation 'com.mpaas.android:media' implementation 'com.mpaas.android:nebula' implementation 'com.mpaas.android:push' implementation 'com.mpaas.android:tinyapp' implementation 'com.mpaas.android:tinyapp-media' implementation 'com.mpaas.android:tinyapp-scan' implementation 'com.mpaas.android:tinyapp-video' implementation 'com.mpaas.android:uccore' implementation 'com.mpaas.android:upgrade' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' //权限申请 implementation 'com.github.tbruyelle:rxpermissions:0.12' implementation 'io.reactivex.rxjava3:rxjava:3.0.4' implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' }
project build.gradle如下:
apply plugin: 'com.alipay.apollo.optimize'// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.mpaas_artifact = "mpaas-baseline" ext.mpaas_baseline = "10.1.68-18" repositories { google() jcenter() maven { url 'http://mvn.cloud.alipay.com/nexus/content/repositories/releases/' name 'alipay' credentials { username 'mvn_read_ws' password 'mrk8929' } } } dependencies { classpath "com.android.tools.build:gradle:4.0.1" classpath 'com.android.boost.easyconfig:easyconfig:2.4.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url 'http://mvn.cloud.alipay.com/nexus/content/repositories/releases/' name 'alipay' credentials { username 'mvn_read_ws' password 'mrk8929' } } maven { url 'https://jitpack.io' } } } task clean(type: Delete) { delete rootProject.buildDir }
方法二:针对老项目
1,在 Project 的 build.gradle 中添加如下代码:
dependencies { classpath 'me.tatarka:gradle-retrolambda:3.2.0' }
2,在 Module 的 build.gradle 中添加如下代码:
// 应用插件 apply plugin: 'me.tatarka.retrolambda' // 支持Java8 android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
分类:
Android
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理