问题
This is driving me nuts.
I have two versions of my app, a barebones version and an advanced version. I messed up some modules/plugins in the advanced version so I rebuilt it from scratch in a new directory. Copied all the necessary www/js/img folders to the newly created one.
I verified i have installed all the same plugins, modules and packages - I then am able to build the app successfully and run it successfully. However, any reference to external scripts or files are getting a "404 (Not Found)" error on the console logs. The barebones app can still pull in the google maps script and I have compared the two config.xml files and can't see anything that would cause an issue.
One is in the index.html:
And the other are jpg images loaded from the IONIC website - part of their standard tabs template.
The errors I am getting: Failed to load resource: the server responded with a status of 404 (Not Found) http://maps.google.com/maps/api/js?sensor=false&
and
GET https://pbs.twimg.com/profile_images/514549811765211136/9SgAuHeY.png 404 (Not Found) ionic.bundle.js:11568 ...and 5 more img png/jpg errors similar to this one.
For the life of me I cant' figure out why the newly rebuilt app isn't allowed to pull in external files or scripts. Any and all help is appreciated.
In my config.xml file I have the following defined:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.testapp765534"
version="0.0.1" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>TestApp</name>
<description>
A test mapping app.
</description>
<author href="http://testapp.org/" email="info@testapp.org">
testapp DEV TEAM
</author>
<access origin="*" />
<access origin="http://*.google.com" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<content src="index.html"/>
<platform name="android">
<allow-intent href="market:*" />
</platform>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param onload="true" name="ios-package" value="CDVStatusBar"/>
</feature>
</widget>
For the record I also have the following plugins installed:
android.support.v4 21.0.1 "Android Support v4"
com.google.playservices 23.0.0 "Google Play Services for Android"
com.ionic.keyboard 1.0.4 "Keyboard"
cordova-plugin-device 1.0.0 "Device"
net.orworks.cordovaplugins.cordovasqlite 1.5.0 "CordovaSQLite"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device-motion 0.2.11 "Device Motion"
org.apache.cordova.device-orientation 0.3.11 "Device Orientation"
org.apache.cordova.dialogs 0.3.0 "Notification"
org.apache.cordova.geolocation 0.3.12 "Geolocation"
org.apache.cordova.globalization 0.3.4 "Globalization"
org.apache.cordova.splashscreen 1.0.0 "Splashscreen"
org.apache.cordova.statusbar 0.1.10 "StatusBar"
org.apache.cordova.vibration 0.3.13 "Vibration"
回答1:
Install https://github.com/apache/cordova-plugin-whitelist this plugin then it works.
来源:https://stackoverflow.com/questions/30156888/cordova-cant-access-external-scripts-files-images