【问题标题】:stuck at starting intent main activity react native app卡在启动意图主要活动反应本机应用程序
【发布时间】:2020-04-17 01:32:27
【问题描述】:

尝试在使用 react-native run-android 连接的移动设备上运行 react 本机应用程序。应用构建成功,但应用在打开时崩溃,在命令提示符下卡在Starting: Intent { cpm=com.project.projectname/.MainActivity }

应用程序安装在移动设备上,但总是停止。谁能帮我调试一下,我看不到错误消息在哪里。

这是整个命令提示符输出

C:\xampp\htdocs\projectname>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1109 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
'C:\Users\user' is not recognized as an internal or external command,
operable program or batch file.
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...
Parallel execution with configuration on demand is an incubating feature.

> Configure project :app
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
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)

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from C:\xampp\htdocs\projectname\node_modules\react-native\android

> Task :app:processDebugGoogleServices
Parsing json file: C:\xampp\htdocs\projectname\android\app\google-services.json

> Task :app:processDebugManifest
C:\xampp\htdocs\projectname\android\app\src\main\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 :react-native-camera:compileGeneralDebugJavaWithJavac

> Task :react-native-firebase:compileDebugJavaWithJavac

> Task :app:transformClassesWithFirebasePerformancePluginForDebug
java.lang.ClassNotFoundException: android.graphics.fonts.Font
java.lang.ClassNotFoundException: android.graphics.fonts.Font
java.lang.ClassNotFoundException: android.graphics.fonts.Font
java.lang.ClassNotFoundException: android.graphics.fonts.Font
java.lang.ClassNotFoundException: com.google.firebase.dynamiclinks.DynamicLink$Builder

> Task :app:installDebug
09:26:46 V/ddms: execute: running am get-config
09:26:46 V/ddms: execute 'am get-config' on 'R58M55ASZDM' : EOF hit. Read: -1
09:26:46 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'SM-A105G - 9' for app:debug
09:26:46 D/app-debug.apk: Uploading app-debug.apk onto device 'R58M55ASZDM'
09:26:46 D/Device: Uploading file onto device 'R58M55ASZDM'
09:26:47 D/ddms: Reading file permision of C:\xampp\htdocs\projectname\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
09:26:47 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
09:27:16 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'R58M55ASZDM' : EOF hit. Read: -1
09:27:16 V/ddms: execute: returning
09:27:16 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
09:27:16 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'R58M55ASZDM' : EOF hit. Read: -1
09:27:16 V/ddms: execute: returning
Installed on 1 device.

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

BUILD SUCCESSFUL in 20m 38s
62 actionable tasks: 59 executed, 3 up-to-date
info Connecting to the development server...
info Starting the app...
Starting: Intent { cmp=com.project.projectname/.MainActivity }

【问题讨论】:

  • 欢迎来到SO,请运行adb logcat,在您启动应用程序时捕获并分享日志,这样我们才能找到您真正的问题。
  • 这个帖子太令人失望了,应该撤掉。

标签: android node.js react-native


【解决方案1】:

首先从终端运行这个命令 1. npm 安装 请使用编辑器重新启动整个项目,然后运行以下命令
在这两个命令之前,请检查您本地的 Android SDK 属性...
1. npm 启动 2. npm 运行安卓

【讨论】:

  • npm start return this warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB. info Reloading app... warn No apps connected. Sending "devMenu" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB. info Opening developer menu... 注意:设备已经连接但没有任何反应,我应该在单独的终端上运行 npm run android 吗?
  • 请关闭所有终端并重试
  • 现在返回 To reload the app press "r" To open developer menu press "d" 和 react native 的大标志
  • 在设备上是否成功运行?
  • 在我运行npm startnpm run android 后仍然没有执行命令,需要 20 或 30 分钟
【解决方案2】:

我遇到了同样的问题,我刚刚使用sudo npm run android 命令解决了它。

npm run andoird 的输出不使用sudo

hesam@hesam:~/react-native/MyReactNative$ npm start android

> @ start /home/hesam/react-native/MyReactNative
> react-native start "android"

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in
   /home/hesam/react-native/MyReactNative 

Loading dependency graph, done.

To reload the app press "r"
To open developer menu press "d"

info Opening developer menu...

使用sudonpm run andoird的输出:

hesam@hesam:~/react-native/MyReactNative$ sudo npm start android    
> @ start /home/hesam/react-native/MyReactNative

> react-native start "android"

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in
   /home/hesam/react-native/MyReactNative 

Loading dependency graph, done.

To reload the app press "r"
To open developer menu press "d"

info Opening developer menu...
 BUNDLE  [android, prod] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (604/604), done.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多