Description
Description
I created a react native library using the cmd npx create-react-native-library@0.42.1 my-config
After implementing the code for library, I am able to run the example with library and execute my native code in Android.
However, when I integrate the library to my actual app and run react-native run-android
, it shows the below error log
add_subdirectory given source
"/Users/.../node_modules/my-config/android/build/generated/source/codegen/jni/"
which is not an existing directory.
I checked and saw that
node_modules/my-config/android/build/generated/source
(yes, there is nocodegen/jni
).node_modules/my-config/android/generated/jni
(thejni
folder is here)
Please take a look at the below image for more information
For more information, if I copy the jni
folder to the actual path. I am able to build and use the lib as normal.
Please take a look at the below image for more information
Below are some files which may give you more information about the library's config.
build.gradle (my-config library)
sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}
react-native.config.js (my-config library)
module.exports = {
dependency: {
platforms: {
android: {
cmakeListsPath: 'generated/jni/CMakeLists.txt',
},
},
},
};
autolinking.json (from my actual project)
"dependencies": {
"my-config": {
"root": "/Users/.../node_modules/my-config",
"name": "my-config",
"platforms": {
"ios": {
"podspecPath": "/Users/.../node_modules/my-config/my-config.podspec",
"version": "0.4.0",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "/Users/.../node_modules/my-config/android",
"packageImportPath": "import com.myconfig.MyConfigPackage;",
"packageInstance": "new MyConfigPackage()",
"buildTypes": [],
"libraryName": "RNMyConfigSpec",
"componentDescriptors": [],
"cmakeListsPath": "/Users/.../node_modules/my-config/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"isPureCxxDependency": false
}
}
}
},
Please let me know if you need any information or have any question.
Many thanks!
Packages
- create-react-native-library
- react-native-builder-bob
Selected options
- Turbo module
- Kotlin & Objective C
- Vanilla
Link to repro
sorry this is a private source
Environment
System:
OS: macOS 15.0.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 53.69 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.12.2
path: /usr/local/bin/node
Yarn:
version: 3.6.4
path: /usr/local/bin/yarn
npm:
version: 10.8.1
path: /usr/local/bin/npm
Watchman:
version: 2024.07.01.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.0
- iOS 18.0
- macOS 15.0
- tvOS 18.0
- visionOS 2.0
- watchOS 11.0
Android SDK:
API Levels:
- "28"
- "30"
- "31"
- "33"
- "34"
Build Tools:
- 28.0.3
- 29.0.2
- 30.0.2
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 34.0.0
- 35.0.0
System Images:
- android-34 | Google APIs Intel x86_64 Atom
- android-34 | Google Play Intel x86_64 Atom
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2024.1 AI-241.19072.14.2412.12360217
Xcode:
version: 16.0/16A242d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.9
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.75.4
wanted: 0.75.4
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: false