MetaMask / MetaMask/metamask-sdk
[Bug]: unable to run SDK in a project, syntax issues from the SDK
- Dominant language
- TypeScript
- Stars
- 338
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
### SDK
React-Native
### Provide environment information
1. windows 11.
2. java 17 (open jdk)
### MetaMask SDK Version
0.3.12
### MetaMask Mobile app Version
7.46.2
### What browser are you using? (if relevant)
no
### How are you deploying your application? (if relevant)
_No response_
### Describe the Bug
The npm run android throws a syntax issue from the SDK
PS {path_to_my_project}\react-native-sample> npm run android
> my_app@0.0.1 android
> react-native run-android
info Installing the app...
> Task :metamask_sdk-react-native:generateCodegenSchemaFromJavaScript
> Task :metamask_sdk-react-native:compileDebugKotlin
w: Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (17) and 'compileDebugKotlin' (11).
This will become an error in Gradle 8.0.
Consider using JVM Toolchain: https://kotl.in/gradle/jvm/toolchain
Learn more about JVM-target validation: https://kotl.in/gradle/jvm/target-validation
> Task :metamask_sdk-react-native:compileDebugKotlin FAILED
[Incubating] Problems report is available at: {path_to_my_project}/android/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.14.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
50 actionable tasks: 40 executed, 10 up-to-date
info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor
No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.
e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:140:29 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableMap?'.
e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:141:35 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableMap?'.
e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:182:45 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableMap?'.
e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:183:49 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableArray?'.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':metamask_sdk-react-native:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more 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 24s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
No modules to process in combine-js-to-schema-cli. If this is unexpected, please check if you set up your NativeComponent correctly. See combine-js-to-schema.js for how codegen finds modules.
e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:140:29 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableMap?'. e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:141:35 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableMap?'. e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:182:45 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableMap?'. e: {path_to_my_project}/node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt:183:49 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'ReadableArray?'. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':metamask_sdk-react-native:compileDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more 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 24s.
info Run CLI with --verbose flag for more details.
### Expected Behavior
after install and set up as per readme the project should run
### Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://github.com/Arthur-Kamau/react-native-sample
### To Reproduce
1. npm i
2. npm run android
(assuming you have adb, device attached, Android SDK, Java 17)
Contributor guide
Research direction
Reproduce the failure with the linked react-native-sample project using npm i and npm run android. Inspect node_modules/@metamask/sdk-react-native/android/src/main/java/io/metamask/reactnativesdk/MetaMaskReactNativeSdkModule.kt at lines 140-141 and 182-183, then verify the Android build completes with Java 17 and the documented setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, react-native
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100