Android 配置文件在cordova的config.xml中不起作用

Android 配置文件在cordova的config.xml中不起作用,android,cordova,Android,Cordova,有关 我想在AndroidManifest.xml <intent-filter> <action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND_MULTIPLE" /> <category android:name="android.intent.c

有关


我想在
AndroidManifest.xml

<intent-filter>
  <action android:name="android.intent.action.SEND" />
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="*/*" />
</intent-filter>

使用
cordova custom config
设置多同级
元素时,必须确保它们具有唯一的标签属性作为插件。您可以在中看到这一点

比如说:

<custom-config-file target="AndroidManifest.xml" parent="./application/activity/[@android:name='MainActivity']">
    <intent-filter android:label="custom_filter">
        <action android:name="android.intent.action.SEND" />
        <action android:name="android.intent.action.SEND_MULTIPLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="*/*" />
    </intent-filter>
</custom-config-file>

免责声明:我是《科尔多瓦定制配置》的作者(这可能是一个评论,但我没有足够的代表)

我确认:
在Cordova 7.0上不起作用(尽管
起作用),请参阅我的config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget ...>
    <platform name="android">
        <config-file parent="/manifest/application" target="AndroidManifest.xml">
            <test1 />
        </config-file>
        <config-file parent="./application" target="AndroidManifest.xml">
            <test2 />
        </config-file>
    </platform>

❤️ 非常感谢您的关心!我尝试在我的自定义
意图过滤器
标签上设置一个
android:label
。但是带有
android:label=“@string/launcher\u name”
(请参阅我问题的详细信息和上下文)的那个仍然被替换。如果没有它,应用程序将不再显示在启动器上。您可能需要设置父级,使其完全匹配-请查看我的更新应答中的父级属性值通过更改
父级属性,它就像一个符咒!非常感谢!我在等待关于cordova内置支持的答案,否则,我将验证您的答案,以便继续。Cordova CLI中内置的
支持的当前问题是
中的
块在Cordova在本机配置中设置的默认值之前应用,这意味着,如果您的
块修改了与Cordova默认设置相同的本机配置部分,则当Cordova设置其默认设置时,您的更改将消失
cordova自定义配置
通过在
after_prepare
hook(即在cordova之后)上应用更改来解决此问题
<config-file target="AndroidManifest.xml" platform="android" parent="/manifest/application/activity" mode="merge">
  <intent-filter>
    <action android:name="android.intent.action.SEND" />
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
  </intent-filter>
</config-file>
<custom-config-file target="AndroidManifest.xml" parent="./application/activity/[@android:name='MainActivity']">
    <intent-filter android:label="custom_filter">
        <action android:name="android.intent.action.SEND" />
        <action android:name="android.intent.action.SEND_MULTIPLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="*/*" />
    </intent-filter>
</custom-config-file>
<?xml version='1.0' encoding='utf-8'?>
<widget ...>
    <platform name="android">
        <config-file parent="/manifest/application" target="AndroidManifest.xml">
            <test1 />
        </config-file>
        <config-file parent="./application" target="AndroidManifest.xml">
            <test2 />
        </config-file>
    </platform>
cordova-custom-config: Error updating config for platform 'android': Cannot use absolute path on element