I was importing location package, but due to it not being null-safe i had to change to the latest 4.2.0. All dependencies are null-safe, but the location package creates problem in running on android(both emulator and actual device). As showed in the error message below, "-source 7" does not support lambda expression, but i don't know how to tun it in -source 8. I currently use Visual Studio.
The error message is about lambda expressions in the location package
/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 file:
dependencies: flutter: sdk: flutter provider: ^5.0.0 location: ^4.2.0 part of 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" } part of 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 }