无法使Android模拟器(或设备)与本机反应一起工作

时间:2020-08-11 14:17:51

标签: react-native android-studio

因此,我跳入了别人的应用程序,他们无法帮助我解决此问题,但对他们来说“开箱即用” 这样我就可以在终端上成功构建。 但是,当我启动模拟器时,该应用程序将启动,但屏幕黑屏,文本为红色背景:

"unable to load script. Make sure you're either running a Metro server (run 'react-native start) 
or that your bundle 'index.android.bundle' is packaged correctly for release."

如果我按R重新加载,文本将更改:

Could not connect to development server. Try the following to fix the issue: 
Ensure that the packager server is running.
Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices
Ensure Airplane Mode is disabled
If you're on a physical device connected to the machine, run 'adb reverse tcp:8081 tcp:8081'
to forward requests from your device
If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings'
to your machine's IP address and the port of the local dev server - e.g 10.0.1.1:8081

尝试清除缓存,甚至在Linux,Windows和Mac上运行,但都无济于事。 任何建议将不胜感激。

如果我按R,在都会区中的消息是

React Native: No apps connected
sending äreload' to all React Native apps failed. 
Make sure your app is running in the simulator or on a phone...

这是终端转储:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.

For more details, please visit https://support.apple.com/kb/HT208050.
DESKTOP-COA1RAD:~ flowmbair$ cd app-mobile/
DESKTOP-COA1RAD:app-mobile flowmbair$ npx react-native run-android
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - react-native-push-notification (to unlink run: "react-native unlink react-native-push-notification")
  - react-native-share (to unlink run: "react-native unlink react-native-share")
  - react-native-system-setting (to unlink run: "react-native unlink react-native-system-setting")
  - rn-range-slider (to unlink run: "react-native unlink rn-range-slider")
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 1355 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

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

> Task :app:processDebugGoogleServices
Parsing json file: /Users/flowmbair/app-mobile/android/app/google-services.json

> Task :app:installDebug
03:43:18 V/ddms: execute: running am get-config
03:43:18 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
03:43:18 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug
03:43:18 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
03:43:19 D/Device: Uploading file onto device 'emulator-5554'
03:43:19 D/ddms: Reading file permision of /Users/flowmbair/app-mobile/android/app/build/outputs/apk/debug/app-debug.apk as: rw-r--r--
03:43:19 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
03:43:20 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
03:43:20 V/ddms: execute: returning
03:43:20 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
03:43:20 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
03:43:20 V/ddms: execute: returning
Installed on 1 device.

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

BUILD SUCCESSFUL in 19s
427 actionable tasks: 4 executed, 423 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.app/.MainActivity }
DESKTOP-COA1RAD:app-mobile flowmbair$ 

0 个答案:

没有答案