@fullstack78 (kait kait)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

react-nativeを起動したい(環境構築)

解決したいこと

react-nativeを起動したい(環境構築)
アプリ開発初心者です。
環境構築ができず困っております。
何卒お力添え宜しくお願い致します。

例)
react-native環境構築をしています。下記が環境及びインストール実施したものです。
windows11 Home
ReactNative-node15.6.0
nvm 15.6.0
python3
Chocolatey
Nodejs
JDK
React Native CLI
Android Studio
Android SDK

発生している問題・エラー

PS C:\Users\User-name\ReactNative-node15.6.0\test> npx 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 16 workers...
info JS server already running.
�w�肳�ꂽ�p�X��������܂���B
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Observed package id 'platform-tools' in inconsistent location 'C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools' (Expected 'C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools\platform-tools')
Checking the license for package SDK Patch Applier v4 in C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Android Emulator in C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package Android Emulator not accepted.
Checking the license for package Android SDK Tools in C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package Android SDK Tools not accepted.
Checking the license for package Android SDK Build-Tools 30.0.2 in C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package Android SDK Build-Tools 30.0.2 not accepted.
Checking the license for package Android SDK Platform 30 in C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools\licenses
Warning: License for package Android SDK Platform 30 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     patcher;v4 SDK Patch Applier v4
     emulator Android Emulator
     platforms;android-30 Android SDK Platform 30
     build-tools;30.0.2 Android SDK Build-Tools 30.0.2
     tools Android SDK Tools
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools

* 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 4s

error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     patcher;v4 SDK Patch Applier v4
     emulator Android Emulator
     platforms;android-30 Android SDK Platform 30
     build-tools;30.0.2 Android SDK Build-Tools 30.0.2
     tools Android SDK Tools
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: C:\Users\User-name\AppData\Local\Android\Sdk\platform-tools

* 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 4s

    at makeError (C:\Users\User-name\ReactNative-node15.6.0\test\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
    at C:\Users\User-name\ReactNative-node15.6.0\test\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async runOnAllDevices (C:\Users\User-name\ReactNative-node15.6.0\test\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
    at async Command.handleAction (C:\Users\User-name\ReactNative-node15.6.0\test\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
npm ERR! code 1
npm ERR! path C:\Users\User-name\ReactNative-node15.6.0\test
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c react-native run-android

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User-name\AppData\Local\npm-cache\_logs\2022-03-17T05_44_19_901Z-debug.log
PS C:\Users\User-name\ReactNative-node15.6.0\test>

自分で試したこと

npm ERR! path C:\Users\User-name\ReactNative-node15.6.0\test
→パスが通っていないのかと思い
$ENV:Path+=";C:\Users\User-name\ReactNative-node15.6.0\test"
としましたが不可。
windowsでも環境変数で追加しましたが不可。

npx react-native startは正常に動作しているように見えます。
同時に立ち上げているエミュレーターはスマホ画面とホーム画面は出ていますが、Welocome to Reactは出ていません。

ネット記事を探していると
HAXMがwindows Homeで対応していないという記事を目にしたのですが関係あるか分からず、、
https://www.javadrive.jp/android/emulator/index9.html
確かにインストールしようとすると弾かれました。

何卒宜しくお願い致します。

0 likes

1Answer

これが問題だと思います。

> Failed to install the following Android SDK packages as some licences have not been accepted

Android SDKまわりで、エラーになることはReact Nativeに関わらずFlutterなどでもよくあることなのでご注意ください。

この記事が参考になると思います。
https://qiita.com/joji/items/931d5f4e4ee853d7458c

0Like

Your answer might help someone💌