dotintent / react-native-ble-plx

React Native BLE library
Apache License 2.0
2.94k stars 492 forks source link

Android build failed: error: cannot find symbol, symbol: variable S #1152

Open gesangseto opened 5 months ago

gesangseto commented 5 months ago

Prerequisites

Library version

3.1.2

Platform

Android

Setup Description

AndroidManifest:

  <uses-permission android:name="android.permission.INTERNET" />
  <!-- Android >= 12 -->
  <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  <!-- Android < 12 -->
  <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />

Steps to Reproduce

react-native run-android

Relevant log output

path-to-project\node_modules\react-native-ble-plx\android\src\main\java\com\bleplx\adapter\BleModule.java:1102: error: cannot find symbol
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                                                        ^
  symbol:   variable S
  location: class VERSION_CODES
path-to-project\node_modules\react-native-ble-plx\android\src\main\java\com\bleplx\adapter\BleModule.java:1114: error: cannot find symbol
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                                                      ^
  symbol:   variable S
  location: class VERSION_CODES
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: path-to-project\node_modules\react-native-ble-plx\android\src\main\java\com\bleplx\adapter\utils\RefreshGattCustomOperation.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-ble-plx: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.

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

BUILD FAILED in 12s

Contents of the package.json file

{
  "name": "XXXX",
  "version": "3.0.0",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "cp -r ./src/lib_node_modules/zebra-browser-print-wrapper/* ./node_modules/zebra-browser-print-wrapper/"
  },
  "dependencies": {
    "@miblanchard/react-native-slider": "^2.0.1",
    "@react-native-community/toolbar-android": "^0.2.1",
    "@react-native-picker/picker": "^1.16.5",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.4",
    "axios": "^0.21.1",
    "crypto-js": "^4.1.1",
    "moment-timezone": "^0.5.33",
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-background-timer": "^2.4.1",
    "react-native-ble-plx": "^3.1.2",
    "react-native-camera": "3.8.0",
    "react-native-datawedge-intents": "^0.1.2",
    "react-native-date-picker": "3.4.0",
    "react-native-device-info": "^8.3.3",
    "react-native-form-select-picker": "0.0.12",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-keyboard-aware-scroll-view": "^0.9.4",
    "react-native-loading-spinner-overlay": "^2.0.0",
    "react-native-mmkv-storage": "^0.8.0",
    "react-native-modal": "^13.0.0",
    "react-native-modalize": "^2.0.8",
    "react-native-pda-scan": "^1.0.14",
    "react-native-portalize": "^1.0.7",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^3.1.1",
    "react-native-segmented-control-tab": "^3.4.1",
    "react-native-sound-player": "^0.11.1",
    "react-native-svg": "^12.1.1",
    "react-native-svg-transformer": "^0.14.3",
    "react-native-system-setting": "^1.7.6",
    "react-native-tcp-socket": "^6.0.6",
    "react-native-timeline-flatlist": "^0.8.0",
    "react-native-toast-notifications": "^3.2.2",
    "react-native-vector-icons": "^6.7.0",
    "zebra-browser-print-wrapper": "^0.1.4"
  },
  "devDependencies": {
    "@babel/runtime": "^7.6.0",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.3.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

Additional Information

build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        ndkVersion = "21.1.6352462"
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"

    }
}

Node

node : v16.12.0
npm : 8.1.3
dominik-czupryna-withintent commented 3 months ago

Can you upgrade compileSdkVersion? Build.VERSION_CODES.S was added in API level 31