jibon57 / nativescript-mediafilepicker

A complete file picker solution for NativeScript
Apache License 2.0
51 stars 39 forks source link

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

Open victorevox opened 5 years ago

victorevox commented 5 years ago

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.

jibon57 commented 5 years ago

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

victorevox commented 5 years ago

Awesome!, it works , thanks!

jibon57 commented 5 years ago

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

asciidiego commented 3 years ago

@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 commented 3 years ago

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>
csimpi commented 2 years ago

@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