react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.61k stars 459 forks source link

react_codegen_rnasyncstorage #1052

Open Usama-Saud opened 5 months ago

Usama-Saud commented 5 months ago

What happened?

Cannot specify link libraries for target "react_codegen_rnasyncstorage" which is not built by this project. Call Stack (most recent call first): CMakeLists.txt:31 (include)

Version

1.21.0

What platforms are you seeing this issue on?

System Information

npx react-native run-android

Steps to Reproduce

Screenshot 2024-01-11 153915
karimb11 commented 4 months ago

Issue still occurring on Windows, and MacOS at version 1.22.1

karimb11 commented 4 months ago

Update: after investigating and noticing that the codegen doesn't work for some libraries, I manually ran ./gradlew generateCodegenArtifactsFromSchema and it seems to have solved the issue, I wonder why it doesn't happen automatically when running the build command. @tido64 any recommendations 🙏?

tido64 commented 4 months ago

What version of React Native are you using? What configuration? New Architecture? Please include a minimal repro otherwise we cannot investigate.

karimb11 commented 4 months ago

@tido64 The latest version 0.73.4, Yes new architecture (Hence why I mentioned codegen), can you point me to where the automated codegen happens in React Native pipeline (Similar to the command I manually ran), I can investigate myself and report back 🙏

tido64 commented 4 months ago

@tido64 The latest version 0.73.4, Yes new architecture (Hence why I mentioned codegen), can you point me to where the automated codegen happens in React Native pipeline (Similar to the command I manually ran), I can investigate myself and report back 🙏

It should be in here somewhere or thereabouts: https://github.com/facebook/react-native/blob/v0.73.4/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt

github-actions[bot] commented 2 months ago

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.

pandisFox commented 2 months ago

Any idea how I could fix this while using expo? The command proposed by @karimb11 ran correctly, but when I run npx expo run:android it fails with the same error regardless. I'm still new to react native and expo so excuse me if this question is dumb.

FYI I tried running a boilerplate project using https://github.com/infinitered/ignite which prompts to whether you'd like to use the new architecture and the project doesn't run. Googled for the issue and there is only 1 entry in google, which is this page. Project runs fine without enabling the new architecture. Running on an M2 if it matters.

Thanks @tido64!

alexanderblackh commented 2 months ago

Able to confirm I ran into the exact same issues on Android only using new Arch and 0.74. The above script ./gradlew generateCodegenArtifactsFromSchema solved it.

Info below:

System:
  OS: macOS 14.0
  CPU: (8) arm64 Apple M1 Pro
  Memory: 179.28 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.6.2
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11668458
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: false
{
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",
    "postinstall": "npx pod-install && yarn start"
  },
  "dependencies": {
    "@babel/plugin-proposal-export-namespace-from": "^7.18.9",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@react-native-clipboard/clipboard": "^1.14.1",
    "@react-native-community/blur": "^4.4.0",
    "@react-native-community/netinfo": "^11.3.1",
    "@react-native-cookies/cookies": "^6.2.1",
    "@react-native-menu/menu": "react-native-menu/menu#master",
    "@react-navigation/bottom-tabs": "^6.5.20",
    "@react-navigation/native": "^6.1.17",
    "@react-navigation/native-stack": "^6.9.26",
    "@react-navigation/stack": "^6.3.29",
    "@reduxjs/toolkit": "^2.2.2",
    "@shopify/flash-list": "^1.6.4",
    "@shopify/restyle": "^2.4.2",
    "@sparkfabrik/react-native-idfa-aaid": "^1.1.1",
    "date-fns": "^3.6.0",
    "expo": "^51.0.0-preview.5",
    "expo-image": "^1.12.3",
    "expo-linear-gradient": "^13.0.1",
    "immer": "^10.0.4",
    "lodash": "^4.17.21",
    "luxon": "^3.4.4",
    "react": "18.2.0",
    "react-native": "^0.74.0",
    "react-native-base64": "^0.2.1",
    "react-native-config": "^1.5.1",
    "react-native-context-menu-view": "^1.15.0",
    "react-native-device-info": "^10.13.1",
    "react-native-fbsdk-next": "^12.1.4",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "^2.16.0",
    "react-native-get-random-values": "^1.11.0",
    "react-native-ios-context-menu": "^1.15.3",
    "react-native-kochava-tracker": "^2.7.1",
    "react-native-modal": "^13.0.1",
    "react-native-onesignal": "^5.1.0",
    "react-native-permissions": "^4.1.5",
    "react-native-public-ip": "^1.0.2",
    "react-native-reanimated": "3.9.0-rc.1",
    "react-native-safe-area-context": "4.10.0-rc.1",
    "react-native-screens": "3.31.0-rc.1",
    "react-native-share": "^10.1.0",
    "react-native-svg": "15.2.0-rc.0",
    "react-native-url-polyfill": "^2.0.0",
    "react-native-vector-icons": "^10.0.3",
    "react-native-view-shot": "4.0.0-alpha.0",
    "react-native-webview": "^13.8.4",
    "react-redux": "^9.1.0",
    "redux-persist": "^6.0.0",
    "semver": "^7.6.0",
    "util": "^0.12.5",
    "uuid": "^9.0.1",
    "yup": "^1.4.0",
    "zeego": "^1.10.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "^0.74.81",
    "@react-native/eslint-config": "0.73.2",
    "@react-native/metro-config": "0.73.5",
    "@react-native/typescript-config": "0.73.1",
    "@types/lodash": "^4.17.0",
    "@types/react": "^18.2.6",
    "@types/react-native-vector-icons": "^6.4.18",
    "@types/react-test-renderer": "^18.0.0",
    "@types/uuid": "^9.0.8",
    "babel-jest": "^29.6.3",
    "babel-plugin-module-resolver": "^5.0.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-native-svg-transformer": "^1.3.0",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}
tido64 commented 2 months ago

Everyone, I've tried to reproduce this locally without any luck. On both 0.73 and 0.74, new arch enabled, I was able to build with AsyncStorage just fine. Unless you can create a minimal repro for us, we cannot investigate this issue. Regardless, this suggests to me that it is not an AsyncStorage bug, but an issue somewhere between your setup and the CLI that was used for autolinking. I would suggest that you open issues (or asking questions) in either the react-native repository or in the Expo forum.

alexanderblackh commented 2 months ago

@tido64 I couldn't reproduce this following the exact same steps as created it in the first place for myself, be it from scratch or reverting to the commit prior to 0.74 and doing it all over again. I agree it's likely not an bug with this repo, but something that occurs in the upgrade process or somewhere else in the development pipeline. Should anyone else run into it, it seems most of us solved it by simply clearing Gradle and generateCodegenArtifactsFromSchema, but I do believe your take is right unless new information comes to light.

philipheinser commented 2 months ago

Run into the same issue @alexanderblackh I did a grade clean but it did not help. how do you run generateCodegenArtifactsFromSchema ?

error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/x/node_modules/@react-native/codegen/lib/cli/combine/combine-js-to-schema-cli.js:62 .parseSync(); ^ TypeError: yargs.option(...).option(...).parseSync is not a function at Object.<anonymous> (/Users/x/node_modules/@react-native/codegen/lib/cli/combine/combine-js-to-schema-cli.js:62:4) at Module._compile (node:internal/modules/cjs/loader:1455:14) at Module._extensions..js (node:internal/modules/cjs/loader:1534:10) at Module.load (node:internal/modules/cjs/loader:1265:32) at Module._load (node:internal/modules/cjs/loader:1081:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14) at node:internal/main/run_main_module:28:49 Node.js v22.0.0 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateCodegenSchemaFromJavaScript'.
> Process 'command 'node'' finished with non-zero exit value 1 * Try:
pandisFox commented 2 months ago

Run into the same issue @alexanderblackh I did a grade clean but it did not help. how do you run generateCodegenArtifactsFromSchema ?

error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/x/node_modules/@react-native/codegen/lib/cli/combine/combine-js-to-schema-cli.js:62 .parseSync(); ^ TypeError: yargs.option(...).option(...).parseSync is not a function at Object.<anonymous> (/Users/x/node_modules/@react-native/codegen/lib/cli/combine/combine-js-to-schema-cli.js:62:4) at Module._compile (node:internal/modules/cjs/loader:1455:14) at Module._extensions..js (node:internal/modules/cjs/loader:1534:10) at Module.load (node:internal/modules/cjs/loader:1265:32) at Module._load (node:internal/modules/cjs/loader:1081:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14) at node:internal/main/run_main_module:28:49 Node.js v22.0.0 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateCodegenSchemaFromJavaScript'.
> Process 'command 'node'' finished with non-zero exit value 1 * Try:

@philipheinser run ./gradlew generateCodegenArtifactsFromSchema from the android folder.

raza-jamil-reckon commented 1 month ago

Experiencing this issue too. Running ./gradlew generateCodegenArtifactsFromSchema gives the same error.

fivemru commented 3 weeks ago

@raza-jamil-reckon

try npm install -D yargs@17

or use this solution https://github.com/expo/expo/issues/28494#issuecomment-2081770811