This is a part of my manifest:
You can do this without hardcoding the package name with an additional benefit of being able to run multiple variants on the same device (think release
and debug
with applicationIdSuffix
, see these issues):
Based on FileProvider.java:560
final ProviderInfo info = context.getPackageManager()
.resolveContentProvider(authority, PackageManager.GET_META_DATA);
final XmlResourceParser in = info.loadXmlMetaData( //560
context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
you were using the wrong authority
and it didn't find the ContentProvider
(info == null
).
Change your manifest to (${applicationId}
will be replaced by Manifest Merger)
android:authorities="${applicationId}.share"
and
Uri uri = FileProvider.getUriForFile(context, context.getPackageName() + ".share", result);
The .share
suffix is optional, in case you have a real ContentProvider
which is better to have the package name as the authority.