Skip to content

Scaffold a React Native library: Nitro module #768

Closed
@mensonones

Description

@mensonones

Description

After generated project, i followed steps:

Get started with the project:

yarn

Run the example app on iOS:

yarn example ios

Run the example app on Android:

yarn example android

I ran the command:

yarn example android

I got the error:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/home/jack/PersonalProjects/awesome-library-nitro/android/build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':react-native-awesome-library-nitro'.
> Could not read script '/home/jack/PersonalProjects/awesome-library-nitro/nitrogen/generated/android/awesomelibrarynitro+autolinking.gradle' as it does not exist.

the folder nitrogen was not generated

but since I know a little about Nitro, I already knew what I should do and I accessed it: https://nitro.margelo.com/docs/nitrogen#configuration

after running the command in the root of the project

yarn nitro-codegen

the folder nitrogen was generated

and I re-ran the command

yarn example android

I got the error

BUILD FAILED in 2m 2s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/home/jack/PersonalProjects/awesome-library-nitro/example/node_modules/react-native-nitro-modules/android/src/main/java/com/margelo/nitro/core/HybridObjectRegistry.java:26: warning: [removal] HybridObjectInitializer in com.margelo.nitro.core has been deprecated and marked for removal public static native void registerHybridObjectConstructor(String hybridObjectName, HybridObjectInitializer initializer); ^
1 warning
e: file:///home/jack/PersonalProjects/awesome-library-nitro/android/src/main/java/com/margelo/nitro/awesomelibrarynitro/AwesomeLibraryNitro.kt:3:2 Unresolved reference 'DoNotStrip'. FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-awesome-library-nitro: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 2m 2s.
info Run CLI with --verbose flag for more details.

When I opened the file in question, I saw the code and removed the annotation

Image

I re-ran the command

yarn example android

the project ran without problems

Image

PS: link repository without my change in AwesomeLibraryNitro.kt

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

Nitro Module

Link to repro

https://github.com/mensonones/awesome-library-nitro

Environment

npx react-native info
info Fetching system and libraries information...
System:
OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Memory: 15.98 GB / 31.13 GB
Shell:
version: 5.1.16
path: /bin/bash
Binaries:
Node:
version: 20.12.2
path: /usr/local/bin/node
Yarn:
version: 3.6.1
path: /usr/local/bin/yarn
npm:
version: 10.5.0
path: /usr/local/bin/npm
Watchman:
version: 4.9.0
path: /usr/bin/watchman
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java:
version: 17.0.14
path: /usr/bin/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 15.1.3
wanted: ^15.1.3
react:
installed: 18.3.1
wanted: 18.3.1
react-native: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions