我想通过添加以下代码来编辑我的AndroidManifest.xml:
<compatible-screens>
<screen android:screenDensity="ldpi" android:screenSize="small" />
<screen android:screenDensity="mdpi" android:screenSize="small" />
<screen android:screenDensity="hdpi" android:screenSize="small" />
<screen android:screenDensity="xhdpi" android:screenSize="small" />
<screen android:screenDensity="ldpi" android:screenSize="normal" />
<screen android:screenDensity="mdpi" android:screenSize="normal" />
<screen android:screenDensity="hdpi" android:screenSize="normal" />
<screen android:screenDensity="xhdpi" android:screenSize="normal" />
</compatible-screens>
根据这篇SO帖子:https://stackoverflow.com/a/40446501/5514215可以不使用插件。我使用的是Apache Cordova 7.0.0。
我在config.xml上添加了以下代码:
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/compatible-screens">
<compatible-screens>
<screen android:screenDensity="ldpi" android:screenSize="small" />
<screen android:screenDensity="mdpi" android:screenSize="small" />
<screen android:screenDensity="hdpi" android:screenSize="small" />
<screen android:screenDensity="xhdpi" android:screenSize="small" />
<screen android:screenDensity="ldpi" android:screenSize="normal" />
<screen android:screenDensity="mdpi" android:screenSize="normal" />
<screen android:screenDensity="hdpi" android:screenSize="normal" />
<screen android:screenDensity="xhdpi" android:screenSize="normal" />
</compatible-screens>
</edit-config>
但它没有用。我为目标尝试了多个值,例如&#34; / manifest&#34;,不同的模式,但没有任何工作。就像在我的AndroidManifest中一样,默认情况下我没有兼容屏幕,但我可能需要使用配置文件,所以根据https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#config-file我写了这个:
<config-file target="AndroidManifest.xml" parent="/manifest">
<compatible-screens>
<screen android:screenDensity="ldpi" android:screenSize="small" />
<screen android:screenDensity="mdpi" android:screenSize="small" />
<screen android:screenDensity="hdpi" android:screenSize="small" />
<screen android:screenDensity="xhdpi" android:screenSize="small" />
<screen android:screenDensity="ldpi" android:screenSize="normal" />
<screen android:screenDensity="mdpi" android:screenSize="normal" />
<screen android:screenDensity="hdpi" android:screenSize="normal" />
<screen android:screenDensity="xhdpi" android:screenSize="normal" />
</compatible-screens>
</config-file>
但我的平台/ android / AndroidManifest.xml始终保持不变......
这是我的完整config.xml
<?xml version="1.0" encoding="utf-8"?>
<widget android-versionCode="1" defaultlocale="en-US" id="test.mobile" version="1.34.0" 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" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">
<name>Test</name>
<description>The Test mobile application</description>
<author email="test@test.com" href="http://test.test.com">test</author>
<content src="index.html" />
<access origin="*" />
<vs:features />
<preference name="SplashScreen" value="screen" />
<preference name="windows-target-version" value="8.1" />
<preference name="DisallowOverscroll" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#B62B39" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="AllowInlineMediaPlayback" value="true" />
<preference name="xwalkCommandLine" value="--disk-cache-size=1024'" />
<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 density="ldpi" src="res/icons/android/icon-36-ldpi.png" />
<icon density="mdpi" src="res/icons/android/icon-48-mdpi.png" />
<icon density="hdpi" src="res/icons/android/icon-72-hdpi.png" />
<icon density="xhdpi" src="res/icons/android/icon-96-xhdpi.png" />
</platform>
<platform name="ios">
<icon height="180" src="res/icons/ios/icon-60-3x.png" width="180" />
<icon height="60" src="res/icons/ios/icon-60.png" width="60" />
<icon height="120" src="res/icons/ios/icon-60-2x.png" width="120" />
<icon height="76" src="res/icons/ios/icon-76.png" width="76" />
<icon height="152" src="res/icons/ios/icon-76-2x.png" width="152" />
<icon height="40" src="res/icons/ios/icon-40.png" width="40" />
<icon height="80" src="res/icons/ios/icon-40-2x.png" width="80" />
<icon height="57" src="res/icons/ios/icon-57.png" width="57" />
<icon height="114" src="res/icons/ios/icon-57-2x.png" width="114" />
<icon height="72" src="res/icons/ios/icon-72.png" width="72" />
<icon height="144" src="res/icons/ios/icon-72-2x.png" width="144" />
<icon height="29" src="res/icons/ios/icon-small.png" width="29" />
<icon height="58" src="res/icons/ios/icon-small-2x.png" width="58" />
<icon height="50" src="res/icons/ios/icon-50.png" width="50" />
<icon height="100" src="res/icons/ios/icon-50-2x.png" width="100" />
</platform>
<platform name="windows">
<icon height="150" src="res/icons/windows/Square150x150Logo.scale-100.png" width="150" />
<icon height="360" src="res/icons/windows/Square150x150Logo.scale-240.png" width="360" />
<icon height="30" src="res/icons/windows/Square30x30Logo.scale-100.png" width="30" />
<icon height="310" src="res/icons/windows/Square310x310Logo.scale-100.png" width="310" />
<icon height="44" src="res/icons/windows/Square44x44Logo.scale-100.png" width="44" />
<icon height="106" src="res/icons/windows/Square44x44Logo.scale-240.png" width="106" />
<icon height="70" src="res/icons/windows/Square70x70Logo.scale-100.png" width="70" />
<icon height="71" src="res/icons/windows/Square71x71Logo.scale-100.png" width="71" />
<icon height="170" src="res/icons/windows/Square71x71Logo.scale-240.png" width="170" />
<icon height="50" src="res/icons/windows/StoreLogo.scale-100.png" width="50" />
<icon height="120" src="res/icons/windows/StoreLogo.scale-240.png" width="120" />
<icon height="150" src="res/icons/windows/Wide310x150Logo.scale-100.png" width="310" />
<icon height="360" src="res/icons/windows/Wide310x150Logo.scale-240.png" width="744" />
</platform>
<platform name="wp8">
<icon height="99" src="res/icons/wp8/ApplicationIcon.png" width="99" />
<icon height="159" src="res/icons/wp8/Background.png" width="159" />
</platform>
<platform name="android">
<splash density="land-hdpi" src="res/screens/android/screen-hdpi-landscape.png" />
<splash density="land-ldpi" src="res/screens/android/screen-ldpi-landscape.png" />
<splash density="land-mdpi" src="res/screens/android/screen-mdpi-landscape.png" />
<splash density="land-xhdpi" src="res/screens/android/screen-xhdpi-landscape.png" />
<splash density="port-hdpi" src="res/screens/android/screen-hdpi-portrait.png" />
<splash density="port-ldpi" src="res/screens/android/screen-ldpi-portrait.png" />
<splash density="port-mdpi" src="res/screens/android/screen-mdpi-portrait.png" />
<splash density="port-xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />
</platform>
<platform name="ios">
<splash height="480" src="res/screens/ios/screen-iphone-portrait.png" width="320" />
<splash height="960" src="res/screens/ios/screen-iphone-portrait-2x.png" width="640" />
<splash height="1024" src="res/screens/ios/screen-ipad-portrait.png" width="768" />
<splash height="2048" src="res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash height="768" src="res/screens/ios/screen-ipad-landscape.png" width="1024" />
<splash height="1536" src="res/screens/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash height="1136" src="res/screens/ios/screen-iphone-568h-2x.png" width="640" />
<splash height="1334" src="res/screens/ios/screen-iphone-portrait-667h.png" width="750" />
<splash height="2208" src="res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />
<splash height="1242" src="res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />
</platform>
<platform name="windows">
<splash height="300" src="res/screens/windows/SplashScreen.scale-100.png" width="620" />
<splash height="1920" src="res/screens/windows/SplashScreen.scale-240.png" width="1152" />
<splash height="1920" src="res/screens/windows/SplashScreenPhone.scale-240.png" width="1152" />
</platform>
<platform name="wp8">
<splash height="1280" src="res/screens/wp8/SplashScreenImage.png" width="768" />
</platform>
<preference name="target-device" value="handset" />
<preference name="android-minSdkVersion" value="21" />
<preference name="android-targetSdkVersion" value="23" />
<preference name="Orientation" value="portrait" />
<config-file parent="/manifest" target="AndroidManifest.xml">
<compatible-screens>
<screen android:screenDensity="ldpi" android:screenSize="small" />
<screen android:screenDensity="mdpi" android:screenSize="small" />
<screen android:screenDensity="hdpi" android:screenSize="small" />
<screen android:screenDensity="xhdpi" android:screenSize="small" />
<screen android:screenDensity="ldpi" android:screenSize="normal" />
<screen android:screenDensity="mdpi" android:screenSize="normal" />
<screen android:screenDensity="hdpi" android:screenSize="normal" />
<screen android:screenDensity="xhdpi" android:screenSize="normal" />
</compatible-screens>
</config-file>
<plugin name="at.modalog.cordova.plugin.cache" spec="https://github.com/moderna/cordova-plugin-cache" />
<plugin name="cordova-plugin-camera" spec="2.3.1" />
<plugin name="cordova-plugin-compat" spec="1.1.0" />
<plugin name="cordova-plugin-crosswalk-webview" spec="2.3.0" />
<plugin name="cordova-plugin-device" spec="1.1.4" />
<plugin name="cordova-plugin-dialogs" spec="1.3.1" />
<plugin name="cordova-plugin-file" spec="https://github.com/apache/cordova-plugin-file" />
<plugin name="cordova-plugin-geolocation" spec="2.4.1" />
<plugin name="cordova-plugin-media" spec="https://github.com/apache/cordova-plugin-media">
<variable name="MICROPHONE_USAGE_DESCRIPTION" value="speech recognition" />
</plugin>
<plugin name="cordova-plugin-screen-orientation" spec="1.4.2" />
<plugin name="cordova-plugin-statusbar" spec="2.2.2" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="ionic-plugin-keyboard" spec="2.2.1" />
</widget>