ionic 3: black screen with Android App on device

2019-02-13 19:46发布

问题:

Yesterday, I built and run my app on my Android device and this version worked fine.

Since, I improved my app (content view and controller of some modules) and today, I have a black screen on device.

Tests where app is OK

  • When I execute ionic serve
  • When I build another Ionic app (not this one) and run on device

Tests where app fails on device

  • When I execute ionic cordova run android --debug
  • When I use the same version like yesterday
  • When I try to rebuild a already tagged version (So qualified and tested)

I think that maybe my build configuration is corrupted but I don't know how.

I tried to:

  • remove and re-add Android platform
  • re-install all NPM modules

but nothing these steps does not fix the issue.

On device, I can't access to "Inspect device" tool of Chrome to see if I have JS problem.

Do you have any idea to resolve my problem please?

EDIT

After more tests, I found the following behavior:

If I change the ID of <widget id="new-app-id"> in config.xml, app runs fine on device!

Any idea on this behavior?

Thanks!

回答1:

After many tests and research, I found the root cause and can solve the issue.

Solution

Remove the plugin cordova-plugin-facebook4 and re-add it with SDK VERSION to 4.35.0 For older cordova-android version, the version shall be defined as described here

So, run:

ionic cordova plugin remove cordova-plugin-facebook4
ionic cordova plugin add cordova-plugin-facebook4 --variable APP_ID="<APP-ID>" --variable APP_NAME="<APP-NAME>" --variable ANDROID_SDK_VERSION="4.35.0"

Root cause

As decribed in this post, Facebook SDK version 4.36.0 is not stable and causes the stuck in main thread.

This behavior is visible on my App (with "monitor tools" of Android SDK)



回答2:

The reason is some application with your previous app-id(package name) is already installed on your device. Uninstall that application and try with your previous app-id and it should work.