question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

android.app.Application cannot be cast to com.facebook.react.ReactApplication

See original GitHub issue

After install the UIExplorer Example via adb install /xxx/.../app-debug.apk, but failed to lauch it.

adb logcat, give me the following error logs.

E/AndroidRuntime(32698): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.react.uiapp/com.facebook.react.uiapp.UIExplorerActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.facebook.react.ReactApplication
E/AndroidRuntime(32698):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2341)
E/AndroidRuntime(32698):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
E/AndroidRuntime(32698):    at android.app.ActivityThread.access$800(ActivityThread.java:154)
E/AndroidRuntime(32698):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
E/AndroidRuntime(32698):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(32698):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(32698):    at android.app.ActivityThread.main(ActivityThread.java:5298)
E/AndroidRuntime(32698):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(32698):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(32698):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:910)
E/AndroidRuntime(32698):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:705)
E/AndroidRuntime(32698): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.facebook.react.ReactApplication
E/AndroidRuntime(32698):    at com.facebook.react.ReactActivity.getReactNativeHost(ReactActivity.java:79)
E/AndroidRuntime(32698):    at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:107)
E/AndroidRuntime(32698):    at com.facebook.react.uiapp.UIExplorerActivity.onCreate(UIExplorerActivity.java:44)
E/AndroidRuntime(32698):    at android.app.Activity.performCreate(Activity.java:6049)
E/AndroidRuntime(32698):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
E/AndroidRuntime(32698):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2294)
E/AndroidRuntime(32698):    ... 10 more

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

47reactions
greena13commented, Jul 7, 2016

@pauliusuza Adding the following to AndroidManifest.xml seems to have fixed for me - or at least changed the error that I am getting - trying to solve that now.

 <application
   android:name=".MainApplication"
12reactions
dsimmonscommented, Jul 19, 2016

Just ran into this myself while upgrading 0.28.0 -> 0.29.2.

Running react-native upgrade made all of the appropriate changes automatically _EXCEPT_ the change mentioned above.

For posterity:

<!-- $PWD/android/app/src/main/AndroidManifest.xml -->

    <application
      android:name=".MainApplication"
Read more comments on GitHub >

github_iconTop Results From Across the Web

android.app.Application cannot be cast to com.facebook.react ...
react-native upgrade. And I'm getting the error when I try to build the app: android.app.Application cannot be cast to com.facebook.react.ReactApplication.
Read more >
Fix Application crash Error “android.app.Application cannot be ...
FATAL EXCEPTION, Fix Application crash Error “ android. app. Application cannot be cast to”#FataException #RuntimeException #JavaException.
Read more >
Android app application cannot be cast to com facebook react ...
Inconvertible types cannot cast android app activity ... You should import the fragment class "android.app.Fragment" and not the "android.support.v4.app.Fragment" ...
Read more >
android.app.Application cannot be cast to com.facebook.react ...
Adding the following to AndroidManifest.xml should solve the error: <application android:name=".MainApplication"
Read more >
Integration with an Android Fragment - React Native
The guide for Integration with Existing Apps details how to ... need to implement the ReactApplication interface in your main Application ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found