Flutter编译运行android问题之JVM版本问题

错误1:

FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':audioplayers_android:compileDebugKotlin'. > Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (21). Consider using JVM Toolchain: https://kotl.in/gradle/jvm/toolchain Learn more about JVM-target validation: https://kotl.in/gradle/jvm/target-validation

* Try:

> Run with --stacktrace option to get the stack trace.

> Run with --info or --debug option to get more log output.

> Run with --scan to get full insights.

> Get more help at https://help.gradle.org.

BUILD FAILED in 1s

错误2:

FAILURE: Build failed with an exception.

* What went wrong:

Could not determine the dependencies of task ':audioplayers_android:compileDebugKotlin'.

> Unknown Kotlin JVM target: 21

* Try:

> Run with --stacktrace option to get the stack trace.

> Run with --info or --debug option to get more log output.

> Run with --scan to get full insights.

> Get more help at https://help.gradle.org.

BUILD FAILED in 1s

解决方案:

1.首先找到依赖项目的路径:

audioplayers: ^4.1.0 存放路径

On Windows:
复制代码
C:\Users\<Your-Username>\AppData\Local\Pub\Cache\hosted\pub.dev\audioplayers-4.1.0
On macOS/Linux:
复制代码
~/.pub-cache/hosted/pub.dev/audioplayers-4.1.0

实际我的路径是:~/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-4.1.0

audioplayers-4.1.0对应的依赖:

查看pubspec.yaml中的:

修改同目录下audioplayers_android-3.0.2/android/build.gradle

添加:

android{

...

...

compileOptions {

sourceCompatibility = 21

targetCompatibility = 21

}

kotlinOptions {

jvmTarget = '21'

}

}

相关推荐
yejqvow121 天前
CSS如何控制placeholder文字的颜色_使用--placeholder伪元素
jvm·数据库·python
m0_743623921 天前
HTML怎么创建多语言切换器_HTML语言选择下拉结构【指南】
jvm·数据库·python
pele1 天前
Angular 表单中基于下拉选择动态启用字段必填校验的完整实现
jvm·数据库·python
HHHHH1010HHHHH1 天前
Redis怎样判断节点是否主观下线_哨兵基于down-after-milliseconds参数的心跳超时判定
jvm·数据库·python
哑巴湖小水怪1 天前
Android的架构是四层还是五层
android·架构
qq_654366981 天前
CSS如何处理@import样式表的嵌套加载_评估递归对加载的影响
jvm·数据库·python
weixin_381288181 天前
苹果微软双修党福音:Navicat如何跨系统平滑迁移配置
jvm·数据库·python
qq_342295821 天前
CSS如何制作点击展开时的手风琴动画_平滑过渡max-height高度
jvm·数据库·python
2501_916008891 天前
深入解析iOS应用启动性能优化策略与实践
android·ios·性能优化·小程序·uni-app·cocoa·iphone
m0_748920361 天前
Golang goquery怎么解析HTML_Golang goquery教程【核心】
jvm·数据库·python