question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lambda expressions are not supported in -source 7

See original GitHub issue

Hi. When running app using command: npx react-native run-android or building with Android Studio, it always returns this error: node_modules/react-native-ble-manager/android/src/main/java/it/innove/BleManager.java:747: error: lambda expressions are not supported in -source 7 scanManager.stopScan(args -> {}); ^ (use -source 8 or higher to enable lambda expressions) To Reproduce Steps to reproduce the behavior:

  1. After install all packages
  2. Start app by command: npx react-native run-android
  3. See error

Expected behavior It must build the app successfully.

Screenshots Having the same error when building by Android Studio: Screen Shot 2022-06-10 at 17 00 25

Smartphone (please complete the following information):

  • Device: Samsung A52s 5G
  • OS: Android 12
  • react-native-ble-manager version: 8.3.0
  • react-native version: 0.66.0

android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 23
        compileSdkVersion = 31
        targetSdkVersion = 31
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.6.0')
    }
}

Full error log

> Task :react-native-ble-manager:generateDebugBuildConfig UP-TO-DATE
> Task :react-native-ble-manager:compileDebugRenderscript NO-SOURCE
> Task :react-native-ble-manager:generateDebugResValues UP-TO-DATE
> Task :react-native-ble-manager:generateDebugResources UP-TO-DATE
> Task :react-native-ble-manager:packageDebugResources UP-TO-DATE
> Task :react-native-ble-manager:parseDebugLocalResources UP-TO-DATE
> Task :react-native-ble-manager:processDebugManifest UP-TO-DATE
> Task :react-native-ble-manager:generateDebugRFile UP-TO-DATE
> Task :react-native-ble-manager:javaPreCompileDebug UP-TO-DATE

> Task :react-native-ble-manager:compileDebugJavaWithJavac FAILED
10 actionable tasks: 2 executed, 8 up-to-date
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
/Users/canhqn/Documents/cartek/node_modules/react-native-ble-manager/android/src/main/java/it/innove/BleManager.java:747: error: lambda expressions are not supported in -source 7
            scanManager.stopScan(args -> {});
                                      ^
  (use -source 8 or higher to enable lambda expressions)
1 error

FAILURE: Build failed with an exception.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
phamhien2102commented, Jul 28, 2022

I also faced this issue (release 8.4.0). My solution: Firstly, add lines into node_modules/react-native-ble-manager/android/build.gradle (link)

        // Add these lines
	compileOptions {
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
	}

	defaultConfig {
		minSdkVersion safeExtGet("minSdkVersion", 21)
	}

Finally, I used patch-package to patch this library, please run this command in terminal:

yarn patch-package react-native-ble-manager

So, hope this help everybody

0reactions
MuriloBarrancocommented, Aug 5, 2022

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compilation failure: lambda expressions are not supported in
java - Compilation failure: lambda expressions are not supported in -source 7 - Stack Overflow. Stack Overflow for Teams – Start collaborating ...
Read more >
lambda expressions are not supported in -source 7 - B4X
I can bypass the lambdas. Now I get package android.os.Bundle does not exist when I am pointing to Android 28 or 30.
Read more >
lambda expressions are not supported in -source 7 #1 - GitHub
pub-cache/hosted/pub.dartlang.org/startapp_sdk-0.1.5/android/src/main/java/com/startapp/flutter/sdk/StartAppSdkPlugin.java:90: error: lambda ...
Read more >
Compilation failure lambda expressions are not supported
SYMPTOM. When adding a lambda expression in a java code maven throws the following error: [ERROR] Failed to execute goal org.apache. · CAUSE....
Read more >
Lambda expressions are not supported in source 1.7
As you may have noticed, lambda expressions are not supported in source 1.7. This is because lambdas were added in Java 7 and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found