Cordova Packaging android apk has a blank page (cannot be displayed)

after several twists and turns, the apk file is finally packaged through cordova . However, when it is installed on the phone, it is found that a blank page is displayed.

After searching for

for a long time, I unzipped the apk and opened the assets\ www under the index.html file, and found two problems:

  1. The js file referenced in index.html does not match the packaged file hash (mainly because part of the js file hash does not match);
  2. The css and js referenced in index.html are repeated (twice);

formatted index.html:

npm run buildindex.htmlcssjs apk~~~

:

:apkcordova serve androidhttp://localhost:8000/android/www/index.htmlandroid

:appcssjs...

Mar.24,2021

seems to have nothing to do with Cordova, it's the webpack build script.


thanks for the invitation.
1 put aside cordova, and directly visit the distribution package you generated with a browser to observe the page.
2 initially determined that the path problem led to incorrect resource references.
3 has not encountered the problem of introducing js css files many times. Visual observation may be that webpack is not properly configured.


there are two problems:
1, route patterns cannot use history;
2, axios asynchronous requests have cross-domain problems;

solution reference

Menu