简体   繁体   中英

Cordova 5.3.1 Android app can't access the internet

I am trying to get a very simple cordova application deployed on android. It is supposed to startup and then pull in a list of countries via angular $http and display them.

The image is not displaying either.

In both cases the app can't access the net but I can browse the net on the device and emulator.

<access origin="*" />

If you are using cordova 5 or above, you should use whitelist plugin

Also you should add this to your config.xml:

<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />

You can be more concrete if you want.

And also add this meta to your index.html, or main page

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

There also seems to be a separate issue where freshly created apps, or apps upgraded from older version of Cordova will have cordova-plugin-whitelist@1 installed automatically.

For some reason, this version of plugin does not work when installed in this automatic way (including the version installed by cordova create !) even with proper CSP and access tags.

Removing plugin and replacing it with cordova-plugin-whitelist@latest seems to fix the problem, up to and including to cause subsequent reinstallation of cordova-plugin-whitelist@1 to function properly.

Remove your entire workspace if you are using android 10>

  • <\/li>
  • <\/li><\/ul>

    Install Cordova 8.0 and android 6-8

    "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM