科尔多瓦5.0.0 Android应用程序无法连接到互联网使用的Andr​​oid 4.0.0互联网、连接到、科尔、应用程序

2023-09-05 07:52:28 作者:毁我问我疼不疼你真搞笑

我米发展科尔多瓦applicatin使用Windows 7的仿真器可以用浏览器连接互联网,但应用程序失败,网络错误

检查[这里链接]

使用了最新的Andr​​oid科尔多瓦4.0.0为devleopment

科尔多瓦5.0.0 科尔多瓦 - 安卓4.0.0

我已经添加白名单作为一种新的插件到科尔多瓦项目。这里检查链接

我config.xml文件定义如下,访问被提供给所有的URL。我真的不知道它会出问题。请指点。

 < XML版本=1.0编码=UTF-8&GT?;

   <小部件的xmlns =htt​​p://www.w3.org/ns/widgets
        的xmlns:缺口=htt​​p://phonegap.com/ns/1.0
        的id =com.vs.VSMF
        版本=1.0.0>

    <名称>&VSMF LT; /名称>

    <描述>
        VSMF项目模板。
    < /描述>

    <作者HREF =电子邮件=dong_dh@hotmail.com>
        华东
    < /笔者>

    <! - 
        在这里启用单独的API的权限。
        设备的许可是必需的deviceready事件。
     - >
    <功能名称=htt​​p://api.phonegap.com/1.0/device/>

    <! - 
        如果你不希望任何权限被添加到您的应用程序,添加
        下面的标签到你的config.xml文件;您仍然可以在INTERNET
        允许您的应用程序,这PhoneGap的需要。
     - >
    < preference名=权限的价值=无​​/>

    <! - 自定义的preference元素你的应用程序和平台。 - >
    <! - < preference名=PhoneGap的版本值=3.4.0/> - > <  - 所有:的PhoneGap的最新版本 - >
    < preference名=方向值=默认/> <  - 所有:默认的方式横向和纵向启用 - >
    < preference名=目标设备值=万能/> <  - 所有:可能值的手机,平板电脑或通用 - >
    < preference名=全屏值=真/> <  - 所有:隐藏在屏幕顶部的状态栏 - >
    < preference名=disallowOverscroll值=真/>
    < preference名=webviewbounce值=FALSE/> <  -  IOS:控制屏幕是否反弹的时候超越了前滚动 - >
    < preference NAME =prerendered图标值=真/> <  -  IOS:如果图标为prerendered,内部监督办公室将不适用它的光泽度,以应用程序的用户的主屏幕上的图标 - >
    < preference名=留合的WebView值=FALSE/> <  -  IOS:外部链接应该在默认浏览器中打开,'真'会使用该应用程序住在web视图 - >
    < preference名=IOS-statusbarstyle值=黑色不透明/> <  -  IOS:黑色半透明会出现黑色的,因为PhoneGap的web视图不走的状态栏下方 - >
    < preference名称=检测数据类型值=真/> <  -  IOS:控制是否数据类型(如电话号码和日期)被自动转为由系统链接 - >
    < preference名=退出上挂起值=FALSE/> <  -  IOS:如果设置为true,应用程序将终止时,home键是pressed  - >
    < preference名=显示,启动画面微调值=真/> <  -  IOS:如果设置为false,微调不会在应用程序加载出现在启动屏幕上 - >
    < preference NAME =自动隐藏,闪屏的价值=FALSE/> <  -  IOS:如果设置为false,闪屏必须使用的JavaScript API被隐藏 - >
    < preference名=AutoHideSplashScreen值=FALSE/>
    < preference名=SplashScreenDelay值=60000/>
    < preference名=禁用光标值=FALSE/> <  - 黑莓:prevents鼠标图标/光标被显示在应用程序 - >
    < preference名=Android的的minSdkVersion值=17/> !<  - 机器人:支持在目标设备上最小的SDK版本。 MAX版本默认为空。 - >
    < preference名=Android的INSTALLLOCATION值=自动/> <  - 机器人:应用程序的安装位置。 '自动'会选择。 internalOnly是设备内存。 'preferExternal'是SD卡。 - >
    < preference名=iosExtraFilesystems值=图书馆,图书馆非同步,文档,文档,非同步,高速缓存,捆绑,根/>
    < preference名=iosPersistentFileLocation值=库/>
    < preference名=AndroidExtraFilesystems值=文件,文件,外部文件,SD卡,高速缓存,缓存外,根/>
    < preference名=AndroidPersistentFileLocation值=内部/>
    <! - 插件也可以在这里添加。 - >
    <! - 
        <差距:插件名称=示例/>
        可在https://m.xsw88.com/allimgs/daicuo/20230905/1730.png/>
    <图标SRC =RES /图标/安卓/图标-36 ldpi.png的差距:平台=Android的差距:密度=LDPI/>
    <图标SRC =RES /图标/安卓/图标-48 mdpi.png的差距:平台=Android的差距:密度=MDPI/>
    <图标SRC =RES /图标/安卓/图标-72-hdpi.png的差距:平台=Android的差距:密度=华电国际/>
    <图标SRC =RES /图标/安卓/图标-96 xhdpi.png的差距:平台=Android的差距:密度=xhdpi/>
    <图标SRC =RES /图标/黑莓/图标 -  80.png的差距:平台=黑莓/>
    <图标SRC =RES /图标/黑莓/图标 -  80.png的差距:平台=黑莓的差距:状态=悬停/>
    <图标SRC =RES /图标/ IOS /图标 -  57.png的差距:平台=IOSWIDTH =57高度=57/>
    <图标SRC =RES /图标/ IOS /图标 -  72.png的差距:平台=IOSWIDTH =72高度=72/>
    <图标SRC =RES /图标/ IOS /图标57-2x.png的差距:平台=IOSWIDTH =114HEIGHT =114/>
    <图标SRC =RES /图标/ IOS /图标72-2x.png的差距:平台=IOSWIDTH =144HEIGHT =144/>
    <图标SRC =RES /图标/的webOS /图标 -  64.png的差距:平台=webOS的/>
    <图标SRC =RES /图标/ Windows的手机/图标48.png的差距:平台=winphone/>
    <图标SRC =RES /图标/ Windows的手机/图标173.png的差距:平台=winphone的差距:角色=背景/>

    <! - 定义应用程序启动屏幕为每个平台。 - >
    <差距:飞溅SRC =RES /屏幕/安卓/屏幕LDPI-portrait.png的差距:平台=Android的差距:密度=LDPI/>
    <差距:飞溅SRC =RES /屏幕/安卓/屏幕MDPI-portrait.png的差距:平台=Android的差距:密度=MDPI/>
    <差距:飞溅SRC =RES /屏幕/安卓/屏幕HDPI-portrait.png的差距:平台=Android的差距:密度=华电国际/>
    <差距:飞溅SRC =RES /屏幕/安卓/屏幕xhdpi-portrait.png的差距:平台=Android的差距:密度=xhdpi/>
    <差距:飞溅SRC =RES /屏幕/黑莓/屏幕225.png的差距:平台=黑莓/>
    <差距:飞溅SRC =RES /屏幕/ IOS /屏幕与iPhone portrait.png的差距:平台=IOSWIDTH =320HEIGHT =480/>
    <差距:飞溅SRC =RES /屏幕/ IOS /屏幕iphone画像,2x.png的差距:平台=IOSWIDTH =640HEIGHT =960/>
    <差距:飞溅SRC =RES /屏幕/ IOS /屏幕的iPad,portrait.png的差距:平台=IOSWIDTH =768HEIGHT =1024/>
    <差距:飞溅SRC =RES /屏幕/ IOS /屏幕的iPad,landscape.png的差距:平台=IOSWIDTH =1024高度=768/>
    <差距:飞溅SRC =RES /屏幕/窗口电话/屏幕portrait.jpg的差距:平台=winphone/>

    <! - 
        定义访问外部域。

        <接入/> - 一个空白的访问标记拒绝访问所有外部资源。
        <获得原产地=*/> - 通配符访问标记允许访问所有外部资源。

        否则,您可以指定特定的域:
     - >
    <获得原产地=*/> <! - 让当地的网页 - >
    <允许导航HREF =*/>
    &所述;允许意图的href =*/>
    <! - 
        <获得原产地=htt​​p://phonegap.com/> - 允许http://phonegap.com/任何安全要求
        <获得原产地=htt​​p://phonegap.com子域=真/> - 同上,但包括子域,如http://build.phonegap.com/
        <获得原产地=htt​​p://phonegap.combrowserOnly =真/> - 仅允许http://phonegap.com到由子浏览器打开。
     - >

   < /部件>
 

在androidmenifest.xml文件,权限也给出

 <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
 

解决方案

我很抱歉,你添加的内容,安全性策略的meta标签?如果将内容安全,政策元不正​​确,可能会导致这个问题。

I m developing the cordova applicatin using windows 7. The emulator can connect internet with browser but the app failed with network error

check the [link here]

Using the the latest cordova android 4.0.0 for devleopment

Cordova 5.0.0 Cordova-android 4.0.0

I have already added the whitelist as a new plugin to the cordova project. check the link here

My config.xml file is defined as below, the access is given to all URL. I really dont know where it could go wrong. Please advice.

   <?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.vs.VSMF"
        version   = "1.0.0">

    <name>VSMF</name>

    <description>
        VSMF project template.
    </description>

    <author href="" email="dong_dh@hotmail.com">
        Hua Dong
    </author>

    <!--
        Enable individual API permissions here.
        The "device" permission is required for the 'deviceready' event.
    -->
    <feature name="http://api.phonegap.com/1.0/device" />

    <!--
        If you do not want any permissions to be added to your app, add the
        following tag to your config.xml; you will still have the INTERNET
        permission on your app, which PhoneGap requires.
    -->
    <preference name="permissions"                value="none"/>

    <!-- Customize your app and platform with the preference element. -->
    <!-- <preference name="phonegap-version"      value="3.4.0" /> -->      <!-- all: current version of PhoneGap -->
    <preference name="orientation"                value="default" />        <!-- all: default means both landscape and portrait are enabled -->
    <preference name="target-device"              value="universal" />      <!-- all: possible values handset, tablet, or universal -->
    <preference name="fullscreen"                 value="true" />           <!-- all: hides the status bar at the top of the screen -->
    <preference name="disallowOverscroll"         value="true" />
    <preference name="webviewbounce"              value="false" />           <!-- ios: control whether the screen 'bounces' when scrolled beyond the top -->
    <preference name="prerendered-icon"           value="true" />           <!-- ios: if icon is prerendered, iOS will not apply it's gloss to the app's icon on the user's home screen -->
    <preference name="stay-in-webview"            value="false" />          <!-- ios: external links should open in the default browser, 'true' would use the webview the app lives in -->
    <preference name="ios-statusbarstyle"         value="black-opaque" />   <!-- ios: black-translucent will appear black because the PhoneGap webview doesn't go beneath the status bar -->
    <preference name="detect-data-types"          value="true" />           <!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system -->
    <preference name="exit-on-suspend"            value="false" />          <!-- ios: if set to true, app will terminate when home button is pressed -->
    <preference name="show-splash-screen-spinner" value="true" />           <!-- ios: if set to false, the spinner won't appear on the splash screen during app loading -->
    <preference name="auto-hide-splash-screen"    value="false" />           <!-- ios: if set to false, the splash screen must be hidden using a JavaScript API -->
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="SplashScreenDelay"          value="60000" />
    <preference name="disable-cursor"             value="false" />          <!-- blackberry: prevents a mouse-icon/cursor from being displayed on the app -->
    <preference name="android-minSdkVersion"      value="17" />              <!-- android: MIN SDK version supported on the target device. MAX version is blank by default. -->
    <preference name="android-installLocation"    value="auto" />           <!-- android: app install location. 'auto' will choose. 'internalOnly' is device memory. 'preferExternal' is SDCard. -->
    <preference name="iosExtraFilesystems" value="library,library-nosync,documents,documents-nosync,cache,bundle,root" />
    <preference name="iosPersistentFileLocation" value="Library" />
    <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />
    <preference name="AndroidPersistentFileLocation" value="Internal" />
    <!-- Plugins can also be added here. -->
    <!--
        <gap:plugin name="Example" />
        A list of available plugins are available at https://build.phonegap.com/docs/plugins
    -->
    <gap:plugin name="org.apache.cordova.console" />
    <gap:plugin name="org.apache.cordova.network-information" />

    <!-- Define app icon for each platform. -->
    <icon src="icon.png" />
    <icon src="res/icon/android/icon-36-ldpi.png"   gap:platform="android"    gap:density="ldpi" />
    <icon src="res/icon/android/icon-48-mdpi.png"   gap:platform="android"    gap:density="mdpi" />
    <icon src="res/icon/android/icon-72-hdpi.png"   gap:platform="android"    gap:density="hdpi" />
    <icon src="res/icon/android/icon-96-xhdpi.png"  gap:platform="android"    gap:density="xhdpi" />
    <icon src="res/icon/blackberry/icon-80.png"     gap:platform="blackberry" />
    <icon src="res/icon/blackberry/icon-80.png"     gap:platform="blackberry" gap:state="hover"/>
    <icon src="res/icon/ios/icon-57.png"            gap:platform="ios"        width="57" height="57" />
    <icon src="res/icon/ios/icon-72.png"            gap:platform="ios"        width="72" height="72" />
    <icon src="res/icon/ios/icon-57-2x.png"         gap:platform="ios"        width="114" height="114" />
    <icon src="res/icon/ios/icon-72-2x.png"         gap:platform="ios"        width="144" height="144" />
    <icon src="res/icon/webos/icon-64.png"          gap:platform="webos" />
    <icon src="res/icon/windows-phone/icon-48.png"  gap:platform="winphone" />
    <icon src="res/icon/windows-phone/icon-173.png" gap:platform="winphone"   gap:role="background" />

    <!-- Define app splash screen for each platform. -->
    <gap:splash src="res/screen/android/screen-ldpi-portrait.png"  gap:platform="android" gap:density="ldpi" />
    <gap:splash src="res/screen/android/screen-mdpi-portrait.png"  gap:platform="android" gap:density="mdpi" />
    <gap:splash src="res/screen/android/screen-hdpi-portrait.png"  gap:platform="android" gap:density="hdpi" />
    <gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:density="xhdpi" />
    <gap:splash src="res/screen/blackberry/screen-225.png"         gap:platform="blackberry" />
    <gap:splash src="res/screen/ios/screen-iphone-portrait.png"    gap:platform="ios"     width="320" height="480" />
    <gap:splash src="res/screen/ios/screen-iphone-portrait-2x.png" gap:platform="ios"     width="640" height="960" />
    <gap:splash src="res/screen/ios/screen-ipad-portrait.png"      gap:platform="ios"     width="768" height="1024" />
    <gap:splash src="res/screen/ios/screen-ipad-landscape.png"     gap:platform="ios"     width="1024" height="768" />
    <gap:splash src="res/screen/windows-phone/screen-portrait.jpg" gap:platform="winphone" />

    <!--
        Define access to external domains.

        <access />            - a blank access tag denies access to all external resources.
        <access origin="*" /> - a wildcard access tag allows access to all external resource.

        Otherwise, you can specify specific domains:
    -->
    <access origin="*"/> <!-- allow local pages -->
    <allow-navigation href="*" />
    <allow-intent href="*" />
    <!--
        <access origin="http://phonegap.com" />                    - allow any secure requests to http://phonegap.com/
        <access origin="http://phonegap.com" subdomains="true" />  - same as above, but including subdomains, such as http://build.phonegap.com/
        <access origin="http://phonegap.com" browserOnly="true" /> - only allows http://phonegap.com to be opened by the child browser.
    -->

   </widget>

in the androidmenifest.xml file , the permission is also given

 <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

解决方案

I am so Sorry, do you add Content-Security-Policy meta tag?if you set Content-Security-Policy meta incorrect,it may cause this problem.