Cordova打包apk遇到的问题

401 阅读1分钟

一、http请求不通的问题;
(1)、检查android:usesCleartextTraffic="true"是否配置; 在/你的项目/platforms/android/app/src/main中的AndroidManifest.xml,应该是下面这样

<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">

(2)、如果上述方法还不行,请继续按下面的方案修改:

// 路径是:/你的项目/platforms/android/CordovaLib/src/org/apache/cordova/ConfigXmlParser.java

private static String SCHEME_HTTP = "http";
// 把https 改成 http 即可
private static String SCHEME_HTTPS = "https";

二、配置全屏;
(1)、项目的根目录下的config.xml增加如下代码;

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    ...
    <!--前面省略了一部分-->
    <content src="index.html" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <!--配置WebView全屏-->
    <preference name="Fullscreen" value="true" />
    <!--后面省略了一部分-->
    ...
</widget>