Sorry, I have some problems in my Xamarin Forms aplication, I am trying to trigger the installation of the application using this code:
public void LetsInstall(string filepath)
{
Java.IO.File file = new Java.IO.File(filepath);
Context context = Android.App.Application.Context;
Android.Net.Uri path = FileProvider.GetUriForFile(context, context.PackageName + ".provider", file);
if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
{
Android.Net.Uri URIAPK = FileProvider.GetUriForFile(context, context.ApplicationContext.PackageName + ".provider", (Java.IO.File)filepath);
Intent intS = new Intent(Intent.ActionView);
intS.SetData(URIAPK);
intS.SetFlags(ActivityFlags.GrantReadUriPermission);
Android.App.Application.Context.StartActivity(intS);
}
else
{
Android.Net.Uri URIAPK = Android.Net.Uri.FromFile((Java.IO.File)filepath);
Intent intS = new Intent(Intent.ActionView);
intS.SetDataAndType(URIAPK, "application/vnd.android.package-archive");
intS.SetFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(intS);
}
}
But it doesn't work out for me. A Java.Lang.IllegalArgumentException: 'Couldn't find meta-data for provider with authority com.BQproject.betterquestx.provider'
error occurs on line 5
I tried to register this code in AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.BQProject.betterquestx" android:installLocation="auto">
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="31" />
<application android:label="BetterQuestX.Android" android:theme="@style/MainTheme" android:icon="@drawable/icon_about">
<provider
android:name="androidx.core.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>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
I also created Resources/xml/provider_paths and added code to it:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="external_files"
path="." />
</paths>
As a result, the resource xml/provider_paths (aka com.BQProject.betterquestx:xml/provider_paths) not found. This error is likely caused by an issue with the AndroidManifest.xml file or an Android manifest generation attribute in a source code file
error appeared and I do not know what to do with it, please help