I’m trying to update native sharing to use FileProvider. I’ve followed and checked multiple instructions from web. I’ve added provider tags to application-part of manifest and created provider paths xml file. In Unity I get the application context, authority string, File object and FileProvider class without problem:
AndroidJavaClass unity = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”);
AndroidJavaObject activity = unity.GetStatic(“currentActivity”);
AndroidJavaObject context = activity.Call(“getApplicationContext”);
string auth = context.Call(“getPackageName”) + “.provider”;
AndroidJavaObject file = new AndroidJavaObject(“java.io.File”, imagePath);
AndroidJavaClass fileProvider = new AndroidJavaClass(“androidx.core.content.FileProvider”);
But as last step when trying to get the URI object:
uriObject = fileProvider.CallStatic(“getUriForFile”, context, auth, file);
I just get exception:
java.lang.NoSuchMethodError: no static method with name=‘getUriForFile’ signature=‘(Landroidx.multidex.MultiDexApplication;Ljava/lang/String;Ljava.io.File;)Ljava/lang/Object;’ in class Landroidx.core.content.FileProvider;
Like whole method doesn’t exist. I thought maybe first parameter is wrong type, can it create similar error? There’s been mixed information what it should be, I’ve also tried to give ‘activity’ directly as context for ‘getUriForFile’. But same error message follows with just different signature.