【问题标题】:How to modify AndroidManifest.xml in a Meteor 1.5 Cordova App?如何在 Meteor 1.5 Cordova App 中修改 AndroidManifest.xml?
【发布时间】:2018-03-28 23:33:44
【问题描述】:

我尝试将我的应用注册到android的共享功能中,我发现我必须修改清单。

我做到了:

App.appendToConfig(`
 <universal-links>
   <host name="com.toto.app" />
 </universal-links>
 <platform name="android">
   <config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
           <intent-filter>               
               <action android:name="android.intent.action.SEND" />
               <category android:name="android.intent.category.DEFAULT" />
               <data android:mimeType="*/*" />                
           </intent-filter>    
   </config-file>
 </platform>
`);

新行出现在 config.xml 中,但意图过滤器未出现在清单中,并且未生成应用程序。

这是错误信息

=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

=> Errors executing Cordova commands:

   While running Cordova app for platform Android with options --device:
   Error: Command failed: C:\dev\https://youtu.be/toto\.meteor\local\cordova-build\platforms\android\cordova\run --device --device
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   C:\dev\toto\.meteor\local\cordova-build\platforms\android\res\xml\config.xml:60: AAPT: Error parsing XML: unbound prefix

   C:\dev\toto\.meteor\local\cordova-build\platforms\android\build\intermediates\res\merged\debug\xml\config.xml:60: error: Error parsing XML: unbound prefix

【问题讨论】:

    标签: cordova meteor android-manifest


    【解决方案1】:

    您需要在每个引用 android 命名空间的元素上使用属性 xmlns:android="http://schemas.android.com/apk/res/android"。在您的情况下,这意味着:

    App.appendToConfig(`
     <universal-links>
       <host name="com.toto.app" />
     </universal-links>
     <platform name="android">
       <config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
               <intent-filter>               
                   <action android:name="android.intent.action.SEND" xmlns:android="http://schemas.android.com/apk/res/android" />
                   <category android:name="android.intent.category.DEFAULT" xmlns:android="http://schemas.android.com/apk/res/android" />
                   <data android:mimeType="*/*" xmlns:android="http://schemas.android.com/apk/res/android" />                
               </intent-filter>    
       </config-file>
     </platform>
    `);
    

    【讨论】:

    • cordova-custom-config:更新平台“android”的配置时出错:无法在元素上使用绝对路径
    • 将 /manifest 替换为 .解决了这个问题,但所有这些都没有任何影响。换句话说,我从图库应用分享了一张照片,但我的应用没有出现在要分享到的应用列表中。
    • 顺便说一句,我试图关注ourcodeworld.com/articles/read/101/… ....到目前为止没有成功。
    • @Marc 我的回答是对错误信息的回应;我建议的更改是将xmlns:android 属性添加到包含任何其他android:* 属性的所有元素中。这解决了您遇到的特定问题。至于新的问题,我不知道答案;但会提出一个新问题。
    猜你喜欢
    • 2015-02-26
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2018-06-04
    相关资源
    最近更新 更多