【问题标题】:Can't run react-native run-android on Mac无法在 Mac 上运行 react-native run-android
【发布时间】:2020-05-16 11:14:43
【问题描述】:

我的 iMac 上有一个完整的 react native 环境,当我运行 react-native run-ios 时项目完全运行,但是当我使用 android 执行此操作时它不起作用,metro bundler 窗口打开但没有t 工作并且不出现任何消​​息。

我要做什么?

我运行“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...

My terminal's print screen after i run android and under it my metro bundler

【问题讨论】:

  • 您能提供更多信息吗?你的 Mac 上也安装了 Android Studio 吗?你能在尝试“react-native run-android”后向我们展示终端日志吗?
  • 是的,我的 Mac 上有 android studio。我复制了我的终端并用日志编辑了问题。

标签: android macos react-native


【解决方案1】:

您似乎没有根据此错误启用“并排 NDK”:

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

打开您的 Android Studio 并安装“NDK(并排)”工具:Android Studio -&gt; Tools -&gt; SDK Manager -&gt; SDK Tools

然后:react-native run-android

希望对你有所帮助。

【讨论】:

    【解决方案2】:

    你试过这个Installing ADB on macOS 吗?之后确保你在做 react-native run-android 之前运行模拟器

    【讨论】:

    • 我现在安装并且模拟器正在运行。我不知道我还能做什么。在 ios 上一切正常,只有在 android 上才会卡在我初始化或继续的所有项目中。
    【解决方案3】:

    从外观上我可以感觉到两个问题:

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

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

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

    npm 似乎无法访问 adb 命令,对此请查看this

    【讨论】:

      猜你喜欢
      • 2021-02-23
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多