如何修改Meteor 1.5 Cordova App中的AndroidManifest.xml?

时间:2017-08-08 16:10:59

标签: cordova meteor android-manifest

我尝试将我的App注册到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中,但intent-filter未显示在清单中,并且未生成应用程序。

这是错误消息

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

1 个答案:

答案 0 :(得分:0)

在引用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>
`);