如何修复Android Cordova应用程序上的“拒绝加载脚本”错误

时间:2019-05-31 17:13:16

标签: cordova

在Android平台上运行cordova应用程序时,我收到了拒绝加载脚本错误

我已卸载并重新安装cordova-plugin-whitelist。我已经将<access origin="*" />添加到了config.xml中。整个作品。

这是错误消息

Refused to load the script 'file://www.radiojar.com/wrappers/api-plugins/v1/player.js?1.65.1t' because it violates the following Content Security Policy directive: 
"script-src 'self' 'unsafe-inline' http://www.radiojar.com/wrappers/api-plugins/v1/player.js http://www.radiojar.com/wrappers/api-plugins/v1/jplayer/jplayer.js http://now-dot-playing-dot-radiojarcom.appspot.com/api/stations/u31u2awpxbwtv/now_playing/". 
Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

这是我的config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="2" id="org.christsheart" version="1.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Christs Heart</name>
    <description>
        Christ's Heart app.
    </description>
    <author email="info@christsheart.org" href="https://christsheart.org">
        Christ's Heart
    </author>
    <preference name="ShowSplashScreenSpinner" value="false" />
    <content src="index.html" />
    <access origin="*" />
    <allow-navigation href="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <access origin="*" />
        <allow-navigation href="*" />
        <allow-intent href="market:*" />
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>
        <icon density="ldpi" src="res/android/ldpi.png" />
        .....
    </platform>
    <platform name="ios">
        <allow-intent href="itms-apps:*" />
        ....
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="1.3.3" />
    <plugin name="cordova-plugin-splashscreen" spec="~5.0.2" />
    <plugin name="cordova-plugin-dialogs" spec="~2.0.1" />
    <plugin name="cordova-plugin-network-information" spec="~2.0.1" />
    <plugin name="cordova-plugin-inappbrowser" spec="~3.0.0" />
    <engine name="android" spec="^8.0.0" />
    <engine name="ios" spec="^5.0.0" />
    <engine name="browser" spec="^6.0.0" />
</widget>

1 个答案:

答案 0 :(得分:1)

我相信是因为您缺少某些权限,请尝试

 script-src 'self' 'unsafe-inline' 'unsafe-eval' *;