Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<my-lib-name>/android/build/generated/source/codegen/jni which is not an existing directory. #647

Closed
1 of 2 tasks
LuongTruong opened this issue Oct 7, 2024 · 2 comments
Closed
1 of 2 tasks
Labels
bug Something isn't working

Comments

@LuongTruong
Copy link

LuongTruong commented Oct 7, 2024

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 no codegen/jni).
  • node_modules/my-config/android/generated/jni (the jni folder is here)
    Please take a look at the below image for more information

Screenshot 2024-10-07 at 11 29 29

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

Screenshot 2024-10-07 at 12 04 20

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
@LuongTruong LuongTruong added the bug Something isn't working label Oct 7, 2024
@johnf
Copy link
Contributor

johnf commented Oct 8, 2024

I think the problem is in the package.json files doesn't include react-native.config.json. I'm about to create a PR

github-merge-queue bot pushed a commit that referenced this issue Oct 11, 2024
…ixes #647 (#648)

### Summary

With the new introduction of
a90142f#diff-4282562f42ade49c2eb46dee36bcbb7987322efec211330f48387a10e5514678R206
that adds `includeGeneratedCode`, `react-native.config.js` needs to be
shipped with the NPM module to signal what directory to use.

### Test plan

Tested `react-native-vector-icons` where I discovered this issue against
my project.
@atlj
Copy link
Collaborator

atlj commented Oct 18, 2024

#648 by @johnf fixes this. We just published 0.42.0 please test it and reopen the issue if this is still a problem 🙌

@atlj atlj closed this as completed Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants