【发布时间】:2021-08-23 23:51:24
【问题描述】:
我正在导入位置包,但由于它不是空安全的,我不得不更改为最新的 4.2.0。所有依赖项都是空安全的,但位置包在 android(模拟器和实际设备)上运行时会产生问题。如下错误信息所示,“-source 7”不支持lambda表达式,但我不知道如何在-source 8中调优。我目前使用Visual Studio。
错误信息是关于位置包中的 lambda 表达式
/home/user/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/location-4.2.0/android/src/main/java/com/lyokone/location/FlutterLocation.java:280: error: lambda expressions are not supported in -source 7
mMessageListener = (message, timestamp) -> {
^
(use -source 8 or higher to enable lambda expressions)
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':location:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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.
pubspec.yaml 文件:
dependencies:
flutter:
sdk: flutter
provider: ^5.0.0
location: ^4.2.0
android/app/build.gradle 的一部分:
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.final7"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
android/build.gradle 的一部分:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】:
标签: java flutter lambda location