I have wrapped a Vue
app into a Cordova container and deployed on Android via Android Studio. Each request that goes out to my server is failing with the message Error: Network Error
.
This is not an issue in browser or iOs.
I have researched this issue and tried various solutions:
I have installed the
cordova-plugin-whitelist
plugin and configured as described in the documentationI have set permissions in the
AndroidManifest.xml
file:
<edit-file mode="merge" parent="/manifest/uses-permission" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</edit-file>
- I have setup a
"Content-Security-Policy"
tag in meta:
<meta data-n-head="1" http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';">
I have changed my server address from
localhost:3000
to my server's IP address as instructed in this answer: Network error with axios and android emulator - I also tried to run it via a local-tunnel to have a "real" API URL - same issueAs instructed in the thread above, I have also added headers:
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json"
Still Error: Network Error
.
I am almost sure this has to do with permissions but there is nothing more I could configure to make it work.
I am testing this on Android 10.0+ device using Cordova 10.
Axios on 0.20.0.