如何修复“拒绝加载脚本" Android Cordova应用程序上的错误 [英] How fix "Refused to load script" error on Android cordova app

查看:74
本文介绍了如何修复“拒绝加载脚本" Android Cordova应用程序上的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm getting a refused to load script error when I run my cordova app on the Android platform

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

I've uninstalled and reinstalled cordova-plugin-whitelist. I've added <access origin="*" /> to my config.xml. The whole works.

这是错误消息

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>

推荐答案

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

I believe it is because you are missing some permissions, try

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

这篇关于如何修复“拒绝加载脚本" Android Cordova应用程序上的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆