React Native issue when newArchEnabled=true in gradle.properties on M1 macs
See original GitHub issueDescription
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
- What went wrong: Could not determine the dependencies of task ‘:app:mergeDebugAssets’.
Could not resolve all task dependencies for configuration ‘:app:debugRuntimeClasspath’. Could not resolve com.facebook.react:react-native:+. Required by: project :app project :app > project :react-native-fbsdk project :app > project :react-native-onesignal project :app > project :react-native-webview project :app > project :react-native-splash-screen project :app > project :invertase_react-native-apple-authentication project :app > project :react-native-async-storage_async-storage project :app > project :react-native-community_masked-view project :app > project :react-native-community_netinfo project :app > project :react-native-google-signin_google-signin project :app > project :react-native-device-info project :app > project :react-native-fast-image project :app > project :react-native-mail project :app > project :react-native-rate project :app > project :react-native-restart project :app > project :react-native-svg project :app > project :react-native-vector-icons project :app > project :react-native-video No matching configuration of project :ReactAndroid was found. The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘debug’ but: - None of the consumable configurations have attributes. Could not resolve project :ReactAndroid. Required by: project :app > project :react-native-gesture-handler project :app > project :react-native-safe-area-context project :app > project :react-native-screens No matching configuration of project :ReactAndroid was found. The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘debug’ but: - None of the consumable configurations have attributes.
- 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 15s
at makeError (/Volumes/development/workingdir/react-woocommerce/testingNewArch/WooComApp/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Volumes/development/workingdir/react-woocommerce/testingNewArch/WooComApp/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Volumes/development/workingdir/react-woocommerce/testingNewArch/WooComApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Volumes/development/workingdir/react-woocommerce/testingNewArch/WooComApp/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
Version
0.68.0-rc.3
Output of npx react-native info
info Fetching system and libraries information… System: OS: macOS 12.2.1 CPU: (8) arm64 Apple M1 Memory: 101.91 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.2 - /usr/local/bin/node Yarn: 1.22.10 - /opt/homebrew/bin/yarn npm: 8.4.1 - /opt/homebrew/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.2 - /Users/adilkhan/.gem/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Android NDK: 22.1.7171670 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7678000 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: 11.0.12 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.0-rc.3 => 0.68.0-rc.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
npx react-native run-android
Snack, code example, screenshot, or link to a repository
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top GitHub Comments
This is a known issue with Android NDK and M1 macs. We described it here: https://reactnative.dev/docs/next/new-architecture-troubleshooting#android-ndk-and-mac-with-m1-apple-silicon-cpus
You currently have some alternatives:
Follow the workaround we suggest on the website, the one linked here: https://github.com/android/ndk/issues/1299. You’ll have to patch a
ndk-build
file inside the NDK folder.Wait for 0.68.1 which will contain this fix. With that no workaround will be needed at all: https://github.com/facebook/react-native/pull/33588
Install the NDK 24 via the SDK manager (in Android studio and do the following):
ndkVersion
insideandroid/app/build.gradle
to be24.0.8215888
Hope this clarifies.
Same problem, I solved it using below method
modify ndk-build file like this https://stackoverflow.com/questions/69541831/unknown-host-cpu-architecture-arm64-android-ndk-siliconm1-apple-macbook-pro