Closed fhintsch closed 4 years ago
What type of project are you building? When the NuGet package is included in a .NET 4.5 (or higher) project, the WPF picker implementation is linked to it, which doesn't exist on VS for Mac.
I want to build for xamarin android. I just cloned the repo. Then changed the target in VS to android. Do I have to configure something before?
Regards Frank
Am 12.03.2020 um 16:44 schrieb vividos notifications@github.com:
What type of project are you building? When the NuGet package is included in a .NET 4.5 (or higher) project, the WPF picker implementation is linked to it, which doesn't exist on VS for Mac.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
When you just want to use the file picker, just use the NuGet package. The build will determine which assembly to use. If you want to build the picker on VS for Mac, e.g. for testing things, edit the Plugin.FilePicker.csproj file and remove all target platforms that your don't have installed.
Many thanks for your help!
My story began, when I added the NuGet package to my project. I coded
try
{
String[] filetypes = new string[1] { "application/pdf" };
FileData fileData = await CrossFilePicker.Current.PickFile(filetypes);
if (fileData == null)
return; // user canceled file picking
and got an exception
[monodroid] JNIEnv.FindClass(Type) caught unexpected exception: Java.Lang.ClassNotFoundException: crc64424a8adc5a1fbe28.FilePickerActivity ---> Java.Lang.ClassNotFoundException: Didn't find class "crc64424a8adc5a1fbe28.FilePickerActivity" on path: DexPathList[[zip file "/data/app/de.rohrleitungsbau_appen.dpclient-GGewsq-I9EJ6UepuG8GjcA==/base.apk"],nativeLibraryDirectories=[/data/app/de.rohrleitungsbau_appen.dpclient-GGewsq-I9EJ6UepuG8GjcA==/lib/x86, /data/app/de.rohrleitungsbau_appen.dpclient-GGewsq-I9EJ6UepuG8GjcA==/base.apk!/lib/x86, /system/lib]]
[monodroid] --- End of inner exception stack trace ---
[monodroid] at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x0006e] in
So I decided to have a look to your original sample. I could not get it running, so I wrote the issue ticket. I still get compilation errors in the dependent Plugin.FilePicker project. The problem is in CrossFilePicker.shared.cs
/// <summary>
/// Creates file picker instance for the platform
/// </summary>
/// <returns>file picker instance</returns>
private static IFilePicker CreateFilePicker()
{
return null;
return new FilePickerImplementation();
}
FilePickerImplementation() could not be resolved. Maybe you think "#if NETSTANDARD1_0 || NETSTANDARD2_0“ should be true. But this is not the case in my environment (VS 2019 for Mac).
Any suggestions? Frank
Am 12.03.2020 um 20:25 schrieb vividos notifications@github.com:
When you just want to use the file picker, just use the NuGet package. The build will determine which assembly to use. If you want to build the picker on VS for Mac, e.g. for testing things, edit the Plugin.FilePicker.csproj file and remove all target platforms that your don't have installed.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows/issues/182#issuecomment-598373120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZENHGYLWBX3VJKCXBXK2DRHEZI3ANCNFSM4LGK7LAA.
I think my original problem is solved, since I added
to AndroidManifest.xml.
Many thanks Frank
Am 13.03.2020 um 10:10 schrieb Frank Hintsch f.hintsch@fhitc.de:
Many thanks for your help!
My story began, when I added the NuGet package to my project. I coded
try { String[] filetypes = new string[1] { "application/pdf" }; FileData fileData = await CrossFilePicker.Current.PickFile(filetypes); if (fileData == null) return; // user canceled file picking
and got an exception
[monodroid] JNIEnv.FindClass(Type) caught unexpected exception: Java.Lang.ClassNotFoundException: crc64424a8adc5a1fbe28.FilePickerActivity ---> Java.Lang.ClassNotFoundException: Didn't find class "crc64424a8adc5a1fbe28.FilePickerActivity" on path: DexPathList[[zip file "/data/app/de.rohrleitungsbau_appen.dpclient-GGewsq-I9EJ6UepuG8GjcA==/base.apk"],nativeLibraryDirectories=[/data/app/de.rohrleitungsbau_appen.dpclient-GGewsq-I9EJ6UepuG8GjcA==/lib/x86, /data/app/de.rohrleitungsbau_appen.dpclient-GGewsq-I9EJ6UepuG8GjcA==/base.apk!/lib/x86, /system/lib]] [monodroid] --- End of inner exception stack trace --- [monodroid] at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x0006e] in
:0 [monodroid] at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue parms) [0x0000e] in:0 [monodroid] at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00018] in :0 [monodroid] at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x0003d] in :0 [monodroid] at Android.Runtime.JNIEnv.FindClass (System.Type type) [0x00015] in :0 [monodroid] --- End of managed Java.Lang.ClassNotFoundException stack trace --- [monodroid] java.lang.ClassNotFoundException: crc64424a8adc5a1fbe28.FilePickerActivity [monodroid] at java.lang.Class.classForName(Native Method) [monodroid] at java.lang.Class.forName(Class.java:453) [monodroid] at crc64ee486da937c010f4.ButtonRenderer.n_onClick(Native Method) [monodroid] at crc64ee486da937c010f4.ButtonRenderer.onClick(ButtonRenderer.java:104) So I decided to have a look to your original sample. I could not get it running, so I wrote the issue ticket. I still get compilation errors in the dependent Plugin.FilePicker project. The problem is in CrossFilePicker.shared.cs
/// <summary> /// Creates file picker instance for the platform /// </summary> /// <returns>file picker instance</returns> private static IFilePicker CreateFilePicker() {
if NETSTANDARD1_0 || NETSTANDARD2_0
return null;
else
return new FilePickerImplementation();
endif
}
FilePickerImplementation() could not be resolved. Maybe you think "#if NETSTANDARD1_0 || NETSTANDARD2_0“ should be true. But this is not the case in my environment (VS 2019 for Mac).
Any suggestions? Frank
Am 12.03.2020 um 20:25 schrieb vividos <notifications@github.com mailto:notifications@github.com>:
When you just want to use the file picker, just use the NuGet package. The build will determine which assembly to use. If you want to build the picker on VS for Mac, e.g. for testing things, edit the Plugin.FilePicker.csproj file and remove all target platforms that your don't have installed.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows/issues/182#issuecomment-598373120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZENHGYLWBX3VJKCXBXK2DRHEZI3ANCNFSM4LGK7LAA.
The plugin uses the classic bait-and-switch pattern. When including the package in a .NET standard project, the assembly with target framework netstandard1.0 (or 2.0) is used. At link time when building the Android project, the build packages the MonoAndroid90 assembly instead (or the appropriate version), which is required to have the same API. I don't know why including the permission fixed the build, though.
Closing this since this project will retire, please check out Xamarin.Essentials which now has a FilePicker based on this one.
Expected Behavior
Compile and run the sample app should work.
Actual Behavior
Compile and link errors are show stoppers:
A step before I excluded FilePickerImplementation.net45.cs from compiling, as references to Microsoft.Win32.OpenFileDialog could not be resolved. Seems to me that something very basic is missing..
Steps to Reproduce the Problem
Specifications