Reputation: 318
I have an phonegap application work very well on Android and Iphone. I have updated my phonegap to the latest version 5.2.2
When i want to build my old application i got some errors so i have add a new platform android to have a clean project.
Now when i start my application on my phone, i have one error :
Failed to load resource: the server responded with a status of 404 (Not Found) http://maps.google.com/maps/api/js?sensor=true
I don't understand why i got this because I have on my manifest the internet permission. I also have the access-origin="*" in my config.xml
If someone got a clue.
Thanks for your futur answers.
Manifest.xml :
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10100" android:versionName="1.1.0" android:windowSoftInputMode="adjustPan" package="com.caligeo.xxxxxx" xmlns:android="http://schemas.android.com/apk/res/android">
<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" />
<application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:launchMode="singleTop" android:name=".MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.plugin.gcm.PushHandlerActivity" />
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.caligeo.xxxxxx" />
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.caligeo.xxxxxx.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.caligeo.xxxxxx.permission.C2D_MESSAGE" />
</manifest>
config.xml :
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.caligeo.xxxxxx" version="1.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>xxxxxx</name>
<description>
xxxxxx mobile
</description>
<author email="[email protected]" href="http://www.yyyyyy.com">
yyyyyy
</author>
<preference name="phonegap-version" value="3.5.0" />
<preference name="orientation" value="portrait" />
<preference name="permissions" value="none" />
<preference name="DisallowOverscroll" value="true" />
<preference name="webviewbounce" value="false" />
<feature name="http://api.phonegap.com/1.0/geolocation" />
<feature name="http://api.phonegap.com/1.0/network" />
<feature name="http://api.phonegap.com/1.0/notification" />
<preference name="keepRunning" value="true" />
<icon src="icon.png" />
<icon gap:platform="ios" height="57" src="img/icons/ios/logo_appli_57x57.png" width="57" />
<icon gap:platform="ios" height="72" src="img/icons/ios/logo_appli_72x72.png" width="72" />
<icon gap:platform="ios" height="114" src="img/icons/ios/logo_appli_114x114.png" width="114" />
<icon gap:platform="ios" height="76" src="img/icons/ios/logo_appli_76x76.png" width="76" />
<icon gap:platform="ios" height="120" src="img/icons/ios/logo_appli_120x120.png" width="120" />
<icon gap:platform="ios" height="152" src="img/icons/ios/logo_appli_152x152.png" width="152" />
<gap:splash src="splash.png" />
<gap:splash gap:platform="ios" height="1136" src="img/splash/ios/splash_iphone5.png" width="640" />
<gap:platform name="ios" />
<gap:platform name="android" />
<gap:plugin name="org.apache.cordova.inappbrowser" version="0.2.3" />
<gap:plugin name="org.apache.cordova.dialogs" version="0.2.2" />
<gap:plugin name="org.apache.cordova.device-orientation" version="0.3.1" />
<gap:plugin name="org.apache.cordova.core.geolocation" version="0.3.7" />
<gap:plugin name="org.apache.cordova.network-information" version="0.2.7" />
<gap:plugin name="com.phonegap.plugins.pushplugin" version="2.1.1" />
<gap:plugin name="org.apache.cordova.statusbar" />
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<content src="index.html" />
<gap:config-file parent="CFBundleVersion" platform="ios">
<string>1.1.0</string>
</gap:config-file>
<gap:config-file parent="CFBundleShortVersionString" platform="ios">
<string>1.1.0</string>
</gap:config-file>
<access origin="*" />
<engine name="android" spec="~4.1.1" />
</widget>
Edit 1:
I have tried to add the CSP, so to allow my script from maps.google.com i have used this meta tag :
<meta http-equiv="Content-Security-Policy" content="script-sr 'unsafe-inline' 'unsafe-eval' 'self' https://maps.google.com">
and i get this error :
Refused to load the script 'http://maps.google.com/maps/api/js?sensor=true' because it violates the following Content Security Policy directive: "script-src 'unsafe-inline' 'unsafe-eval' 'self' https://maps.google.com".
Upvotes: 0
Views: 808
Reputation: 349
Looks like cordova 5.2.2 is forcing to use cordova-plugin-whitelist.
I tried re-creating cordova project, re-add plugins, platforms etc Modified www/index.html to include appropriate CSP as suggested in https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy.
Now the app works as expected.
Alternatively may be we can try adding cordova-plugin-whitelist to existing project, update index.html for CSP and try build again. I did not try this.
Upvotes: 1