我的Cordova应用程序在iOS和Android调试中运行良好,但在Android发布模式下无法连接到其REST服务器

slmsl1lt  于 2022-11-15  发布在  iOS
关注(0)|答案(1)|浏览(152)

我一直在开发这个应用程序在各种伪装了一段时间,但当试图发布最新版本,当我为Play商店构建Android发布版本时,它无法连接到后端REST服务器。这只发生在Google停止接受.apk构建并坚持应用捆绑后。我研究了许多关于Stack Overflow的解决方案,但似乎没有一个适合我的情况。REST服务器通过端口8443上的HTTPS进行通信,该端口的证书来自主流的证书颁发机构。

<content src="index.html" />
    <access origin="https://www.samoperational.co.uk" />
    <allow-intent href="https://www.samoperational.co.uk/*" />
    <icon src="icon.png" />    
    <splash src="splashscreen.png" />
    <preference name="Orientation" value="portrait" />
    <config-file target="AndroidManifest.xml" parent="/*" mode="merge">
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.INTERNET" />
    </config-file>
    <platform name="android">
        <preference name="AndroidXEnabled" value="true" />
        <preference name="android-targetSdkVersion" value="30" />
        <preference name="AndroidPersistentFileLocation" value="Compatibility" />
        <preference name="android-build-tool" value="gradle" />
        <allow-intent href="market:*" />
        <preference name="splashscreen" value="splashscreen" />
        <preference name="splashScreenDelay" value="10000" />
    </platform>
    <platform name="ios">
        <preference name="scheme" value="app" />
        <preference name="hostname" value="localhost" />        
    <preference name="target-device" value="handset" />
        <icon height="20" src="icons/Icon20x20.png" width="20" />
        <icon height="40" src="icons/Icon40x40.png" width="40" />
        <icon height="180" src="icons/Icon180x180.png" width="180" />
        <icon height="80" src="icons/Logo_80x80.png" width="80" />
        <icon height="120" src="icons/Icon120x120.png" width="120" />
        <icon height="1024" src="icons/Logo_1024x1024.png" width="1024" />
        <splash height="2436" src="icons/SplashScreen1125x2436.png" width="1125" />
        <splash height="1136" src="icons/SplashScreen640x1136.png" width="640" />
        <splash height="1334" src="icons/SplashScreen750x1334.png" width="750" />
        <splash height="2208" src="icons/SplashScreen1242x2208.png" width="1242" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <edit-config target="NSLocationAlwaysUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Location not used by LionRidge</string>
        </edit-config>
        <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Location not used by LionRidge</string>
        </edit-config>
        <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Camera only used for bar code reading when selecting an alternate server</string>
        </edit-config>
        <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Photo library not used by LionRidge</string>
        </edit-config>
    </platform>

然而,尽管access origin和allow-intent指令的目的是限制应用程序只能连接到我自己的服务器,但我后来在配置文件中发现了以下相互矛盾的行:

<access origin="*" />
    <allow-intent href="*" />
    <allow-navigation href="*" />
    <allow-navigation href="file:*" />
wz1wpwve

wz1wpwve1#

正在添加

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

由于某些我不理解的原因,使用config.xml修复了该问题

相关问题