If you try to execute the most normal ajax tasks in your project and you cannot load any external resource (internet images,files etc.) because you'll find that stupid issue net::ERR_CACHE_MISS, then you're in the right place if you want to solve it quickly. This error is pretty common and the reason is indeed, very stupid.
We don't have access to internet ! therefore we need to ask for the right permission from our AndroidManifest.xml
file. However we will not make the changes directly in the AndroidManifest.xml
file, instead we will add it in the config.xml
using the cordova-custom-config
plugin as a good practice.
Adding internet permissions
Although if you use the whitelist plugin, this should automatically the permission for you. Try to remove all the plugins of your projects, remove the android platform and add it again (including the plugins) and that should solve the problem. Remember that you should do this only if you use a plugin that should already add the permission (like cordova-plugin-whitelist).
However, there are always exceptions, if this is your case, you'll need to make some changes to your config.xml
file. But you cannot simply add the permission in the config.xml as it will not work.
To add permissions, you'll need to install the following plugin : cordova-custom-config. This plugin will allow you to add any kind of configuration to your AndroidManifest.xml
file from your config.xml
(you can add directly the permissions in the AndroidManifest.xml
file, however this is not a good practice as you'll lose all the changes on every build). To install the plugin use :
cordova plugin add cordova-custom-config
# Or if you're using phonegap
phonegap plugin add cordova-custom-config
After the installation, only add the following lines into your config.xml
file :
<!-- Note that the lines needs to be inside the android platform -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.INTERNET" />
<!-- And if you need more things about the internet
<uses-permission android:name="android.permissions.NETWORK_ACCESS" />
<uses-permission android:name="android.permissions.ACCESS_NETWORK_STATE" />
-->
</config-file>
</platform>
Now build your app again and try to execute an external request, everything should be working normally now. Have fun