问题
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.
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>
in command-line, re-generate the platform files (android)
ionic cordoba build android
or ionic capacitor build android
- in android studio, re-run the gradle build
来源:https://stackoverflow.com/questions/53044182/ionic-build-failed-unexpected-element-provider-found-in-manifest