Issue
I'm trying to run a react native app on the android emulator (react-native run-android
), however it keeps crashing with the error message "MYAPP has stopped". I'm trying to figure out where I can debug this further (error messages, logs, etc). I don't exactly see any error messages on the terminal nor on the emulator itself. So besides trying to resolve why the app won't deploy ... where does one look to further debug app deployment issues on an android emulator?
Side note: I upgraded from version 0.31.0 to 0.32.0 and ran the react-native upgrade
command, which also required that some files be over-written (I chose the option to overwrite all files). Should I be worried that the latest changes from upgrade to 0.32.0 are not working or incomplete? Any steps I can take to verify that the latest changes are there?
Update: I created a new sample react native project just to see if there was something wrong with RN's latest version. It worked fine. Then took the sample code in index.android.js and overwrote it in my project's index.android.js and re-ran. Still getting the same issue with trying to deploy it to an Android emulator. Removed the node_modules directory, reran, still same issue. I'm now thinking this has something to do with the upgrade process... this is very frustrating.
Update v2: Thanks to @GabeSechan for the hint and direction, here's the stack trace that I found:
09-04 03:24:41.297 5008 5008 E AndroidRuntime: FATAL EXCEPTION: main
09-04 03:24:41.297 5008 5008 E AndroidRuntime: Process: com.helpr, PID: 5008
09-04 03:24:41.297 5008 5008 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.helpr/com.helpr.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.facebook.react.ReactApplication
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.ActivityThread.-wrap12(ActivityThread.java)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6077)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.facebook.react.ReactApplication
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at com.facebook.react.ReactActivity.getUseDeveloperSupport(ReactActivity.java:89)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:96)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6664)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
09-04 03:24:41.297 5008 5008 E AndroidRuntime: ... 9 more
After a quick google search, it seems this is an existing issue when it comes to upgrading React Native. I'll post an answer, answering my own question.
Solution
It turns out that if you are upgrading React Native, be wary that the upgrade process does not necessarily update all the required files (at the time of writing, upgrading to RN 0.32.0). It turns out this is a known issue (https://github.com/facebook/react-native/issues/8215). Until that's resolved, you'll need to manually update the AndroidManifest.xml file located at ./android/app/src/main/AndroidManifest.xml
. I would recommend creating a sample react native project, and using the newly created AndroidManifest.xml from there to manually update the one in your existing project. Also, whenever you upgrade, do a diff between a newly created RN project and your own to verify that no other files need to be updated.
Answered By - Uzair Faisal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.