从Playstore下载的我的应用无法调用网络服务

从Playstore下载的我的应用无法调用网络服务

本文介绍了从Playstore下载的我的应用无法调用网络服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开发了一个cordova应用,该应用已上传到Google Play商店.我在手机和模拟器上测试了这个应用程序数周,一切正常.但是,当我从Playstore下载相同的应用程序时,它无法调用任何Web服务,因此不会显示任何内容.

I recently developed a cordova App that is uploaded to google play store. I tested this app on my mobile and simulators for weeks and everything works fine. However, when i download the same app from the playstore it fails to call any of the web services and such doesn't display any content.

npm:6.10.1

npm : 6.10.1

cordova-android:7.0.0

cordova-android : 7.0.0

我遍历了每一行代码,但似乎找不到问题,我将对window.localStorage的每个调用替换为全局变量,只是为了解决我认为的问题./p>

I have gone through every line of code and i can't seem to find the problem, i replaced every single call to window.localStorage to a global variables just to be able to fix what i thought would be the problem.

<?xml version='1.0' encoding='utf-8'?></code>
<widget defaultlocale="en-US" id="com.test.fr" version="1.0.6" android-versionCode="100050" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">
    <content src="index.html" />
    <access origin="*" />
    <preference name="SplashScreen" value="screen" />
    <preference name="windows-target-version" value="8.1" />
    <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">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <platform name="android">
        <icon src="www/res/icon/android/fr_mobile_icon.png" density="ldpi" />
        <icon src="www/res/icon/android/fr_mobile_icon.png" density="mdpi" />
        <icon src="www/res/icon/android/fr_mobile_icon.png" density="hdpi" />
        <icon src="www/res/icon/android/fr_mobile_icon.png" density="xhdpi" />
    </platform>
    <plugin name="cordova-plugin-device" version="2.0.2" />
    <plugin name="cordova-plugin-websql" version="0.0.10" />
    <plugin name="cordova-plugin-dialogs" version="2.0.1" />
    <plugin name="cordova-plugin-file" version="4.3.3" />
    <preference name="target-device" value="handset" />
    <preference name="BackupWebStorage" value="local" />
    <preference name="android-targetSdkVersion" value="28" />
    <preference name="android-minSdkVersion" value="17" />
    <preference name="android-maxSdkVersion" value="29" />
    <preference name="AndroidPersistentFileLocation" value="Compatibility" />
    <plugin name="cordova-custom-config" spec="5.1.0" />
</widget>

最糟糕的部分....设备上没有显示错误,只是无法正常工作.

Worst part.... No error shown on the device, it just doesn't work.

推荐答案

尝试将android:usesCleartextTraffic="true"添加到AndroidManifest.xml中的<application>或使用config.xml

Try adding android:usesCleartextTraffic="true" to the <application> in the AndroidManifest.xml or as below using config.xml

<platform name="android">
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
      <application android:usesCleartextTraffic="true" />
  </edit-config>
</platform>

明文是任何传输或存储的,不是 加密或打算加密.当应用与之通信时 使用明文网络流量(例如HTTP)的服务器,它可以 会增加窃听和篡改内容的风险,这就是为什么在最新的Android设备中,默认情况下将其设置为false.

Cleartext is any transmitted or stored information that is not encrypted or meant to be encrypted. When an app communicates with servers using a cleartext network traffic, such as HTTP, it could raise a risk of eavesdropping and tampering of content which is why in latest Android devices, it's set to false by default.

这篇关于从Playstore下载的我的应用无法调用网络服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:57