ImagePicker
ImagePicker copied to clipboard
Conflict with authorities for provider on android N+
Hi linchaolong,
I like your image picker but I got troubles using imagePicker on android N. I spent some time looked at it and I realized there is a conflict on one of the data provider. Our data provider often uses ${applicationId}.provider as authorities and your image picker uses the same.
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
public static Uri getContentUri(Context context, Uri fileUri){
return FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", new File(fileUri.getPath()));
}
This is causing the problem because it picks up my another data provider.
I highly recommend you use the more specific name: Here is my recommendation.
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.imagePicker.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
public static Uri getContentUri(Context context, Uri fileUri){
return FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".imagePicker.provider", new File(fileUri.getPath()));
}
If you agree, kindly to take my suggestion. If you don't agree, feel free to drop me an email to discuss.
Thanks Good job.
@ryc16 Thank you for your suggestion,the bug is fixed,you can modify your build.gradle as follows:
compile 'com.linchaolong.android:imagepicker:1.4'