Ionic build failed “unexpected element <provider> found in <manifest>”

纵饮孤独 提交于 2021-01-03 05:39:57

问题


I have this code

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="nl.x-services.plugins.videocaptureplus.provider"
    android:exported="false"
    android:grantUriPermissions="true" >
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths" />
</provider>

But if i try "Ionic cordova run android" i have this error

https://pastebin.com/BAtL0VqK

What can I do with this error?


回答1:


The issue seems to be with VideoCapturePlus as I was getting the same problem. I have swapped it for MediaCapture and no longer have this problem.




回答2:


Try to remove this code from plugin/nl.x-services.plugins.videocaptureplus/plugin.xml




回答3:


I fix editing platform/android/android.json

move the block

step 1 into "Application" block step 2




回答4:


This is the sequence I did

npx cordova platform rm android --nosave
npx ionic cordova plugin rm nl.x-services.plugins.videocaptureplus
npx ionic cordova plugin add https://github.com/Neocrea/cordova-plugin-video-capture-plus\#patch-1
npx ionic cordova platform add android@latest

I used https://github.com/Neocrea/cordova-plugin-video-capture-plus\#patch-1 because it had the requisite patch that fixes the issue. It's not the best solution IMO, instead you should be using media capture plugin instead which is something we are migrating to, but this is a stop gap.




回答5:


There is indeed a <provider> element wrongly injected in the resulting AndroidManifest.xml.
This element comes from the plugin.xml file of the videoCapturePlus plugin.

  1. in file /node_modules/cordova-plugin-video-capture-plus/plugin.xml, comment out the lines

         <provider
                 android:name="android.support.v4.content.FileProvider"
                 android:authorities="nl.x-services.plugins.videocaptureplus.provider"
                 android:exported="false"
                 android:grantUriPermissions="true">
             <meta-data
                     android:name="android.support.FILE_PROVIDER_PATHS"
                     android:resource="@xml/provider_paths"/>
         </provider>
    
  2. in command-line, re-generate the platform files (android)

ionic cordoba build android or ionic capacitor build android

  1. in android studio, re-run the gradle build


来源:https://stackoverflow.com/questions/53044182/ionic-build-failed-unexpected-element-provider-found-in-manifest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!