我的应用程序正在使用Xamarin Android。一切正常,但在一台设备(三星平板电脑-记事本10(me302c)(me302c))上,我打电话时应用程序崩溃:
application.context.getexternalfilesdirs
有人知道是什么原因导致这个设备上的错误吗?
这是StackTrace:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:744)
    ... 2 more
Caused by: android.runtime.JavaProxyThrowable: System.TypeInitializationException: The type initializer for 'Newsapp.Helper.Cache' threw an exception. ---> Java.Lang.LinkageError: no method with name='getExternalFilesDirs' signature='(Ljava/lang/String;)[Ljava/io/File;' in class Landroid/content/ContextWrapper;
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <7f3c44ba97304b1facc5fab710fb48ee>:0
  at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x00068] in <94c0df7d96c545139eb80ed7e7971cad>:0
  at Java.Interop.JniType.GetInstanceMethod (System.String name, System.String signature) [0x0000d] in <94c0df7d96c545139eb80ed7e7971cad>:0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember) [0x00037] in <94c0df7d96c545139eb80ed7e7971cad>:0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00021] in <94c0df7d96c545139eb80ed7e7971cad>:0
  at Android.Content.ContextWrapper.GetExternalFilesDirs (System.String type) [0x00028] in <9034fa2a7b2d4af58a5795347dea0c6c>:0
  at Newsapp.Helper.Cache..cctor () [0x00005] in <3c67df7fed2f4d7f93c20a8efe706c9d>:0
--- End of inner exception stack trace ---
  at Newsapp.MainActivity.OnResume () [0x00006] in <3c67df7fed2f4d7f93c20a8efe706c9d>:0
  at Android.App.Activity.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <9034fa2a7b2d4af58a5795347dea0c6c>:0
  at (wrapper dynamic-method) System.Object:c38d2a60-2f2e-4588-9b3e-9c0127e13614 (intptr,intptr)
    at md5f618e11941113618e86cea743c542a49.MainActivity.n_onResume(Native Method)
    at  md5f618e11941113618e86cea743c542a49.MainActivity.onResume(MainActivity.java:34)
    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
    at android.app.Activity.performResume(Activity.java:5211)
    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2819)
    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2858)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2305)
    at android.app.ActivityThread.access$600(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1295)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:150)
    at android.app.ActivityThread.main(ActivityThread.java:5162)
    ... 5 more

最佳答案

看起来你在这个设备上运行的是果冻豆。

            if (Android.OS.Build.VERSION.SdkInt <= BuildVersionCodes.JellyBeanMr2)
            {
                var files = Application.Context.GetExternalFilesDir(null);
            }
            else // for kitkat and above
            {
                var files = Application.Context.GetExternalFilesDirs(null);
            }

10-08 17:45