guys, I am working on an android application for which I need external application dependency(.aar file) library application has its own file provider and my application have its own.
library work well when I run it as a separate app but when I include it my application then camera functionality not working. I get the following error
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
following the manifest file of the application
<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/file_paths" />
</provider>
and the following is a manifest file of the lib module
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.ma.bot.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
both application and lib module have different package name how I add this 2 file providers into the application I also try including multiple file providers using, but I get XML parse error on app compilation.
android:authorities="${applicationId}.provider;com.ma.bot.provider"
how to solve this.
Guys I found solution on this link Possible to use multiple authorities with FileProvider?
Basically problem is my library and application have same name android.support.v4.content.FileProvider so it colliding in manifest merger, to avoid this I need to defile empty class extending File provider and use it provider name
<provider
android:name="com.MAG.MAGFileProvider"
android:authorities="${applicationId}.provider;"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
and declare class like this
import android.support.v4.content.FileProvider;
public class MAGFileProvider extends FileProvider
{
//we extend fileprovider to stop collision with chatbot library file provider
//this class is empty and used in manifest
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With