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.
For some reason it can't access the internet, to simplify the test, I've added an images tag that displays an image on the net. The image is not displaying either.
I can't get a connection to jsconsole.com working either.
I've tested it on a real device and an emulator. In both cases the app can't access the net but I can browse the net on the device and emulator.
I've included the following in my config.xml
<access origin="*" />
I've also checked the generate AndroidManifest.xml file it contains the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
What am I missing?
here is the full config file:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"
id="com.domain.app" version="1.0.0">
<name>app</name>
<description>
A sample Apache Cordova application that responds to the
deviceready
event.
</description>
<author href="http://www.eclipse.org/thym" email="[email protected]">
Eclipse.org -
Thym
</author>
<content src="index.html" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="LogLevel" value="VERBOSE" />
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<feature name="Compass">
<param name="android-package"
value="org.apache.cordova.deviceorientation.CompassListener" />
</feature>
<feature name="Device Orientation">
<param name="id" value="cordova-plugin-device-orientation" /></feature>
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device.Device" />
<param name="id" value="cordova-plugin-device" />
</feature>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
<param name="id" value="cordova-plugin-dialogs" /></feature>
<feature name="NetworkStatus">
<param name="android-package"
value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<feature name="Network Information">
<param name="id" value="cordova-plugin-network-information" />
</feature>
<engine name="android" version="4.1.0"/>
</widget>
Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.app"
android:hardwareAccelerated="true"
android:versionCode="100008"
android:versionName="1.0.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:hardwareAccelerated="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true" >
<activity
android:name="com.domain.app.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/activity_name"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustResize" >
<intent-filter android:label="@string/launcher_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
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'">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With