Cordova edit AndroidManifest xml,编辑配置不起作用

Cordova edit AndroidManifest xml,编辑配置不起作用,android,cordova,android-manifest,Android,Cordova,Android Manifest,我想通过添加以下代码来编辑我的AndroidManifest.xml: <compatible-screens> <screen android:screenDensity="ldpi" android:screenSize="small" /> <screen android:screenDensity="mdpi" android:screenSize="small" /> <s

我想通过添加以下代码来编辑我的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>
<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>

根据这篇文章:不使用插件是可能的吗。我正在使用Apache Cordova 7.0.0

我在config.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>
<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>

但它不起作用。我尝试为目标设置多个值,如“/manifest”,不同的模式,但没有任何效果。在我的AndroidManifest中,默认情况下我没有兼容的屏幕,我认为可能我需要使用配置文件,因此根据我写的:

<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>

试验
测试移动应用程序
测试

你能发布整个config.xml吗?所以我注意到,如果你有自定义的config插件,并将config file属性放在config.xml中的android属性下,它会更新AndroidManifest.xml,但是我在编译它时遇到了麻烦。它表示该标记不受支持。在android平台标记下移动标记时,只需将父项更改为/*即可。@jcesarmobile:我已经更新了我的帖子,谢谢。Aleksandr Movsesyan:我不使用自定义配置插件(我也不能,因为它需要一个新版本的节点,这与我的Visual studio构建过程不兼容,需要一个旧版本的节点…),我将尝试使用/*并让您不断更新更新更新日期:通过设置target=“/*”,它也不起作用:-(但我在构建过程中还有一行:'发现冲突,从config.xml编辑配置更改将覆盖plugin.xml更改',这将删除一些插件行…我认为config.xml上还没有实现配置文件,只有编辑配置,对于您来说(添加新元素)您需要配置文件,因为编辑配置用于编辑现有元素。