nativescript-mediafilepicker icon indicating copy to clipboard operation
nativescript-mediafilepicker copied to clipboard

Android Gradle compilation with nativescript-social-share or nativescript-camera

Open victorevox opened this issue 7 years ago • 6 comments

Describe the bug Android Gradle fails compilation when using this plugin with "nativescript-social-share"

To Reproduce Just add the plugin tns plugin add nativescript-social-share on a project with nativescript-mediafilepicker

Expected behavior Both plugins should co-exists on same project

NativeScript Info(please run tns info):

Sample Code(please provide minimum code to reproduce problem): https://github.com/victorevox/nativescript-test/tree/mediafilepicker-socialshare-error

Additional context Error: Attribute meta-data#android.support.FILE_PROVIDER_PATHS@resource value=(@xml/file_paths) from [:MultiTypeFilePicker-release:] AndroidManifest.xml:46:17-51 is also present at [:nativescript_social_share:] AndroidManifest.xml:17:17-55 value=(@xml/provider_paths). Suggestion: add 'tools:replace="android:resource"' to <meta-data> element at AndroidManifest.xml to override.

victorevox avatar Sep 20 '18 22:09 victorevox

Common problem & explained here already: https://github.com/jibon57/nativescript-mediafilepicker/issues/26

You will need to add provider in your AndroidManifest.xml inside <application></application> to override like this:

<provider
	android:name="android.support.v4.content.FileProvider"
	android:authorities="${applicationId}.provider"
	android:exported="false"
	android:grantUriPermissions="true"
	tools:replace="android:authorities">
	<meta-data
		android:name="android.support.FILE_PROVIDER_PATHS"
		android:resource="@xml/file_paths"
		tools:replace="android:resource"/>
</provider>

also xmlns:tools="http://schemas.android.com/tools" in <manifest. So, it will look like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="__PACKAGE__"
	android:versionCode="1"
	android:versionName="1.0"
	xmlns:tools="http://schemas.android.com/tools">

My suggestion will be to remove those from the plugins & implement it to your app directly.

Ref: https://stackoverflow.com/a/48270294/1281864 https://stackoverflow.com/a/27360988/1281864 https://stackoverflow.com/a/50794484/1281864

jibon57 avatar Sep 21 '18 00:09 jibon57

Awesome!, it works , thanks!

victorevox avatar Sep 21 '18 05:09 victorevox

Welcome :) .. I am keeping this issue open so that other may find it quickly.

jibon57 avatar Sep 21 '18 05:09 jibon57

@jibon57 can you explain what "remove those from the plugin and implement in the app directly" mean?

What do you recommend removing and what do you exactly recommend implementing?

asciidiego avatar Oct 22 '20 08:10 asciidiego

BTW, people who currently have this same issue (we had it using {N} v7 on Android with the social share plugin), we fixed it using these lines instead:

<provider
        <!-- notice the `androidx.core` instead of `android.support.v4` -->
        <!-- See: https://github.com/jibon57/nativescript-mediafilepicker/blob/4a3c38ecb06e0483ec49001727bc790e71c0ebf5/src/platforms/android/AndroidManifest.xml#L34 -->
	android:name="androidx.core.content.FileProvider"
	android:authorities="${applicationId}.provider"
	android:exported="false"
	android:grantUriPermissions="true"
	tools:replace="android:authorities">
	<meta-data
		android:name="android.support.FILE_PROVIDER_PATHS"
		android:resource="@xml/file_paths"
		tools:replace="android:resource"/>
</provider>

asciidiego avatar Oct 22 '20 10:10 asciidiego

@jibon57 these are not working for me at all, getting the same error, even I add exactly what the error message suggest, tried all of the solution from this tread also the similar threads, same error. After running clean, the same. Deleting the platforms folder, the same

csimpi avatar Feb 12 '22 04:02 csimpi