System.ArgumentException:无法绑定到方法“ GetGetDefaultCipherSuitesHandler”

时间:2019-05-07 23:19:55

标签: xamarin xamarin.forms

我正在测试一个应用程序,并且看到某些Android设备崩溃。我们在设备日志(和Crashlytics)中看到的错误:

Fatal Exception: android.runtime.JavaProxyThrowable: System.ArgumentException: Couldn't bind to method 'GetGetDefaultCipherSuitesHandler'.
  at System.Delegate.GetCandidateMethod (System.Type type, System.Type target, System.String method, System.Reflection.BindingFlags bflags, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x000f9] in <e5404a7cbaab472a85c87c8c593feada>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x00014] in <e5404a7cbaab472a85c87c8c593feada>:0 
  at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method) [0x00000] in <e5404a7cbaab472a85c87c8c593feada>:0 
  at Android.Runtime.AndroidTypeManager.RegisterNativeMembers (Java.Interop.JniType jniType, System.Type type, System.String methods) [0x00123] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Android.Runtime.JNIEnv.RegisterJniNatives (System.IntPtr typeName_ptr, System.Int32 typeName_len, System.IntPtr jniClass, System.IntPtr methods_ptr, System.Int32 methods_len) [0x00115] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_alloc_object(intptr,intptr&,intptr)
  at Java.Interop.JniEnvironment+Object.AllocObject (Java.Interop.JniObjectReference type) [0x00027] in <55c8950cd1f2461e9c76bad39e8fc8a4>:0 
  at Java.Interop.JniType.AllocObject () [0x0000c] in <55c8950cd1f2461e9c76bad39e8fc8a4>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x00044] in <55c8950cd1f2461e9c76bad39e8fc8a4>:0 
  at Javax.Net.Ssl.SSLSocketFactory..ctor () [0x00034] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Xamarin.Android.Net.OldAndroidSSLSocketFactory..ctor () [0x00010] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Xamarin.Android.Net.AndroidClientHandler.SetupSSL (Javax.Net.Ssl.HttpsURLConnection httpsConnection) [0x00027] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Xamarin.Android.Net.AndroidClientHandler.SetupRequestInternal (System.Net.Http.HttpRequestMessage request, Java.Net.URLConnection conn) [0x0007b] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Xamarin.Android.Net.AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00236] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x000ca] in <0029d260a26b48288c90ea4fe946b24c>:0 
  at MyObfuscatedAppName.Services.CharacterEmbeddedResourceDriver.<LoadCharacters>b__1_0 (System.IObserver`1[T] observer) [0x000ca] in <446b676d44a2438aa46540b6f67c24f8>:0 
  at System.Reactive.PlatformServices.ExceptionServicesImpl.Rethrow (System.Exception exception) [0x00006] in <9ce90c81f389405fa2d38b0e75e8871b>:0 
  at System.Reactive.ExceptionHelpers.Throw (System.Exception exception) [0x0000a] in <99f8205c51c44bb480747b577b8001ff>:0 
  at System.Reactive.Stubs+<>c.<.cctor>b__2_1 (System.Exception ex) [0x00000] in <99f8205c51c44bb480747b577b8001ff>:0 
  at System.Reactive.AnonymousSafeObserver`1[T].OnError (System.Exception error) [0x0000e] in <99f8205c51c44bb480747b577b8001ff>:0 
  at System.Reactive.Concurrency.ObserveOn`1+ObserveOnSink[TSource].OnErrorPosted (System.Object error) [0x00000] in <99f8205c51c44bb480747b577b8001ff>:0 
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <b9d3dca3be2f48d1874313a7a497190a>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.31(intptr,intptr)
       at mono.java.lang.RunnableImplementor.n_run(RunnableImplementor.java)
       at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5479)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
       at dalvik.system.NativeStart.main(NativeStart.java)

似乎该堆栈跟踪中与我们的代码有关的部分:

at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x000ca] in <0029d260a26b48288c90ea4fe946b24c>:0 
  at MyObfuscatedAppName.Services.CharacterEmbeddedResourceDriver.<LoadCharacters>b__1_0 (System.IObserver`1[T] observer) [0x000ca] in <446b676d44a2438aa46540b6f67c24f8>:0 

LoadCharacters()方法开始时可能正在发生:

public IObservable<CharacterJsonRoot> LoadCharacters()
{
    Debug.WriteLine("MyApp :: Load Characters");

    return Observable.Create<CharacterJsonRoot>(async observer =>
    {
        if (CrossConnectivity.Current.IsConnected)
        {
            var client = new HttpClient();
            client.BaseAddress = new Uri("https://myapp.obfuscated.com");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.GetAsync("/my/path/to/file/data.json");
            if (response.IsSuccessStatusCode)
            {
                Debug.WriteLine("Loaded from server");
                var data = await response.Content.ReadAsStringAsync();
                var characters = DeserializeJson(data);
                observer.OnNext(characters);
                observer.OnCompleted();
            }
            else
            {
                Debug.WriteLine("Loaded from fallback");
                var assembly = typeof(CharacterEmbeddedResourceDriver).GetTypeInfo().Assembly;
                var stream = assembly.GetManifestResourceStream("MyApp.Services.Data.data.json");

                using (var reader = new StreamReader(stream))
                {
                    string result = await reader.ReadToEndAsync();
                    var characters = DeserializeJson(result);
                    observer.OnNext(characters);
                    observer.OnCompleted();
                }
            }
        }
        else
        {
            // write your code if there is no Internet available  
            Debug.WriteLine("Loaded from fallback & NO  Internet available ");
                var assembly = typeof(CharacterEmbeddedResourceDriver).GetTypeInfo().Assembly;
                var stream = assembly.GetManifestResourceStream("MyApp.Services.Data.data.json");

                using (var reader = new StreamReader(stream))
                {
                    string result = await reader.ReadToEndAsync();
                    var characters = DeserializeJson(result);
                    observer.OnNext(characters);
                    observer.OnCompleted();
                }
        }
    }).SubscribeOn(System.Reactive.Concurrency.TaskPoolScheduler.Default).ObserveOn(SynchronizationContext.Current);
}

除此之外,我真的不知道为什么仅在某些设备上会发生此错误。我们正在使用浏览器堆栈中的App Live进行测试,它对于Galaxy Note 3和Samsung Tab 4始终会崩溃。例如,它永远不会在Samsung Galaxy S7上崩溃。

更新: 它仅在Android 4.4及更低版本上发生。因此,我通过将最低Android版本设置为5更新了我的Android项目。但是,我仍然想知道为什么会发生此错误及其含义,所以我将其保留为空。

1 个答案:

答案 0 :(得分:0)

我也遇到了这个问题。原来,它Linking太过热情了。将Mono.Android添加到Skip linking assemblies可以为我修复。