当前位置: 首页 > 知识库问答 >
问题:

不能在Mac上运行反应-本机运行-Android

阎庆
2023-03-14

我的iMac上有一个完整的react本机环境,当我运行react本机运行ios时,项目完全运行,但当我使用android执行此操作时,它不工作,metro bundler窗口打开但不工作,并且不显示任何消息。

我必须做什么?

运行“react native run android”后我的终端

Daives-iMac:generico_toaqui_app fourtime$ react-native run-android
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-code-push: https://microsoft.github.io/code-push
  - react-native-maps: https://github.com/react-native-community/react-native-maps#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - @react-native-community/netinfo (to unlink run: "react-native unlink @react-native-community/netinfo")
  - bugsnag-react-native (to unlink run: "react-native unlink bugsnag-react-native")
  - react-native-camera (to unlink run: "react-native unlink react-native-camera")
  - react-native-code-push (to unlink run: "react-native unlink react-native-code-push")
  - react-native-contacts (to unlink run: "react-native unlink react-native-contacts")
  - react-native-device-info (to unlink run: "react-native unlink react-native-device-info")
  - react-native-firebase (to unlink run: "react-native unlink react-native-firebase")
  - react-native-fs (to unlink run: "react-native unlink react-native-fs")
  - react-native-image-picker (to unlink run: "react-native unlink react-native-image-picker")
  - react-native-image-resizer (to unlink run: "react-native unlink react-native-image-resizer")
  - react-native-maps (to unlink run: "react-native unlink react-native-maps")
  - react-native-otp-verify (to unlink run: "react-native unlink react-native-otp-verify")
  - react-native-power-saving-mode (to unlink run: "react-native unlink react-native-power-saving-mode")
  - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons")
  - rethink-gpstracking (to unlink run: "react-native unlink rethink-gpstracking")
  - rethink-material-design (to unlink run: "react-native unlink rethink-material-design")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1891 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

> Configure project :app
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/releaseStaging, src/releaseStaging/nullnull, src/nullnull, src/releaseStaging, src/nullnullReleaseStaging]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /Users/fourtime/Documents/React Native/generico_toaqui_app/node_modules/react-native/android

> Configure project :react-native-image-resizer
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-power-saving-mode
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :rethink-gpstracking
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :rethink-material-design
WARNING: The following project options are deprecated and have been removed: 
android.useDeprecatedNdk
NdkCompile is no longer supported


WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :rethink-utils
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (26.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (23.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.3.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :app:processDebugGoogleServices
Parsing json file: /Users/fourtime/Documents/React Native/generico_toaqui_app/android/app/google-services.json

> Task :app:processDebugManifest
/Users/fourtime/Documents/React Native/generico_toaqui_app/android/app/src/debug/AndroidManifest.xml:24:9-31:50 Warning:
        activity#com.google.firebase.auth.internal.FederatedSignInActivity@android:launchMode was tagged at AndroidManifest.xml:24 to replace other declarations but no other declaration present

> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.

> Task :app:installDebug
04:58:49 V/ddms: execute: running am get-config
04:58:50 V/ddms: execute 'am get-config' on 'S541008694' : EOF hit. Read: -1
04:58:50 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Twist 2 Go - 8.1.0' for app:debug
04:58:50 D/app-debug.apk: Uploading app-debug.apk onto device 'S541008694'
04:58:50 D/Device: Uploading file onto device 'S541008694'
04:58:50 D/ddms: Reading file permision of /Users/fourtime/Documents/React Native/generico_toaqui_app/android/app/build/outputs/apk/debug/app-debug.apk as: rw-r--r--
04:58:52 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
04:59:07 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'S541008694' : EOF hit. Read: -1
04:59:07 V/ddms: execute: returning
04:59:07 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
04:59:08 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'S541008694' : EOF hit. Read: -1
04:59:08 V/ddms: execute: returning
Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 2m 2s
485 actionable tasks: 9 executed, 476 up-to-date
/bin/sh: adb: command not found
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync adb ENOENT
info Starting the app...

运行Android系统后,我的终端的打印屏幕,以及在它下面的metro捆绑包

共有3个答案

邰勇军
2023-03-14

从表面上看,我能感觉到两个问题:

error React Native CLI对本机依赖项使用自动链接,但以下模块是手动链接的:

由于您使用的是RN 0.60或更高版本,它可以自动为您链接某些库,您可以安全地取消这些库的链接。看看这个

/bin/sh: adb:命令未找到

似乎npm无法访问adb命令,对于这一个,请看这个

狄旻
2023-03-14

您是否尝试在macOS上安装ADB?完成此操作后,请确保在执行react native run android之前正在运行模拟器

鲁炳
2023-03-14

看起来你没有根据这个错误启用“NDK并排”:

未找到兼容的并排NDK版本。

打开Android Studio并安装“NDK(并排)”工具:Android Studio-

然后:反应原生运行android

我希望这有帮助。

 类似资料:
  • 当我想运行反应-本机运行-Android命令我看到 失败:构建失败,有一个异常。 > 哪里出错了:配置根项目'reactNativeCliTest'时出现问题。 无法解析配置“:classpath”的所有依赖项。无法下载gradle core。jar(com.android.tools.build:gradle-core:2.2.3)无法获取资源的https://jcenter.bintray.c

  • info JS服务器已在运行。安装应用程序的信息。。。 任务:@react-native-community_datetimepicker:compiledBugJavaWithJavaC 任务:react-nate-fbsdk: compileDebugJavaBackJavac 任务:反应本机手势处理程序:CompiledBugJavaWithJavaC 任务:反应本机映射:CompiledB

  • 我安装了最新版本的Java,当我尝试运行eclipse时,它会说: JVM的版本不适合本产品。版本:需要或更高版本。 为什么?我该怎么办?

  • 失败:生成失败,出现异常。 > 错误:任务“:app:installdebug”执行失败。 com.android.builder.testing.api.deviceException:没有连接的设备! 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。 请访问https://help.gr

  • 我的应用程序在emulator上运行得很好,但当我导出后在我的智能手机(galaxy s3)上运行它时,它会在这个活动中崩溃,因为有HTTP连接!问题出在哪里?代码还是导出?当我点击连接按钮时,它崩溃了。

  • 我在windows上构建了一个react原生应用程序,当我试图在mac上运行它时,它会给我一个错误。只有当我尝试运行Android系统时,它才显示出这个错误,ios运行得非常完美。在我在mac上构建之后,它甚至在之前编码的windows系统中也不会运行。 错误:-