Android-RTEditor icon indicating copy to clipboard operation
Android-RTEditor copied to clipboard

Bug: failure to build because of FileProvider being incorrectly set

Open AndroidDeveloperLB opened this issue 6 years ago • 2 comments

v1.6.7

In the manifest of the library, it has a constant :

android:authorities="com.onegravity.rteditor.fileprovider"

This means, that if I create 2 projects that use this library, and install one, I won't be able to install the other, because of a conflict. And, indeed, the IDE tells me I can't do it:

image

Failure [INSTALL_FAILED_CONFLICTING_PROVIDER: Package couldn't be installed in /data/app/com.example.user.myapplication2-6ioDf0xDgtsWcK3dYn3jKw==: Can't install because provider name com.onegravity.rteditor.fileprovider (in package com.example.user.myapplication2) is already used by com.example.user.myapplication]

Error while Installing APK

Attached 2 sample projects, with identical code yet different package names. In fact, all I did is adding the dependency of the library to both of them. Try to install both on the same device. You will get the error.

MyApplication.zip MyApplication2.zip

AndroidDeveloperLB avatar Mar 07 '18 09:03 AndroidDeveloperLB

I agree with AndroidDeveloperLB. With android:authorities="com.onegravity.rteditor.fileprovider" in the libraries manifest it is not possible to install an App with the RTEditor library if there already is another App with this library installed (e.g. the RTEditor Demo App). Overriding android:authorities in the own manifest with another name is not a solution because then picking a camera image does not work any more.

However, I think there is an easy solution. Replace "com.onegravity.rteditor.fileprovider" with ${applicationId}" In the libraries manifest use: android:authorities="${applicationId}" And in ImageChooserManager.java use: uriForCamera = FileProvider.getUriForFile(mActivity, BuildConfig.APPLICATION_ID, imageFile);

android-outliner avatar Nov 10 '18 21:11 android-outliner

kindly merge this branch so that your library can be used by adding in build.gradle

geeta4 avatar Oct 04 '21 07:10 geeta4