Juno
Juno

Reputation: 31

I can't install android app when react-native project is first created

There is an issue when I create project

yarn run v1.22.17

$ react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 863 file(s) to forward-jetify. Using 10 workers... info JS server already running. info Installing the app...

Task :app:processDebugMainManifest FAILED 11 actionable tasks: 2 executed, 9 up-to-date

FAILURE: Build failed with an exception.

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @3ddaca54

BUILD FAILED in 2s

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.

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @3ddaca54

BUILD FAILED in 2s

at makeError (/Users/junochoi/Documents/ReactNative/TodoApp/node_modules/execa/index.js:174:9)
at /Users/junochoi/Documents/ReactNative/TodoApp/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/junochoi/Documents/ReactNative/TodoApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/junochoi/Documents/ReactNative/TodoApp/node_modules/@react-native-community/cli/build/index.js:192:9)

Here is my $ react-native info

System:
OS: macOS 12.2
CPU: (10) arm64 Apple M1 Pro
Memory: 97.39 MB / 16.00 GB
Shell: 5.8 - /bin/zsh

Binaries: Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v16.14.0/bin/yarn npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm Watchman: 2022.02.14.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 29, 30, 31, 32 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0 System Images: android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs ARM 64 v8a, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play ARM 64 v8a, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64, android-30 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-30 | Google Play ARM 64 v8a, android-31 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a, android-31 | Google APIs Intel x86 Atom_64, android-32 | Google Play ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8139111 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: 17.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.2 => 0.67.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Upvotes: 1

Views: 341

Answers (1)

Juno
Juno

Reputation: 31

I was able to solve the problem by adding the code below to gradient.properties.

org.gradle.jvmargs=-Xmx1536M —add-exports=java.base/sun.nio.ch=ALL-UNNAMED —add-opens=java.base/java.lang=ALL-UNNAMED —add-opens=java.base/java.lang.reflect=ALL-UNNAMED —add-opens=java.base/java.io=ALL-UNNAMED —add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

Upvotes: 2

Related Questions