question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ICharacteristic.WriteAsync(byte[]) Error on Android 5.0.1

See original GitHub issue

Caused by: android.runtime.JavaProxyThrowable: Plugin.BLE.Abstractions.Exceptions.CharacteristicReadException: Gatt write characteristic FAILED. at Plugin.BLE.Android.Characteristic.InternalWrite (System.Byte[] data) [0x00054] in <5d0080769b114fa0ac55d0d5e8f42614>:0 at Plugin.BLE.Android.Characteristic+<>c__DisplayClass19_0.<WriteNativeAsync>b__0 () [0x00000] in <5d0080769b114fa0ac55d0d5e8f42614>:0 at Plugin.BLE.Abstractions.Utils.TaskBuilder+<FromEvent>d__13[TReturn,TEventHandler,TRejectHandler].MoveNext () [0x000b3] in <17233c4b6076471cb4183230850d0bba>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at Plugin.BLE.Android.Characteristic+<WriteNativeAsync>d__19.MoveNext () [0x000dc] in <5d0080769b114fa0ac55d0d5e8f42614>:0 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at Plugin.BLE.Abstractions.CharacteristicBase+<WriteAsync>d__27.MoveNext () [0x000b1] in <17233c4b6076471cb4183230850d0bba>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at WeatherMonitor.PageTab+<SendToDevice>d__18.MoveNext () [0x00072] in <939c423dfe1e41988295c028824d3434>:0 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in <a709efbb17bf4aa7b8d27ea8973c7f4c>:0 at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in <b56096d9aca04f2d9c2570e7f66fd957>:0 at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <b56096d9aca04f2d9c2570e7f66fd957>:0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <b56096d9aca04f2d9c2570e7f66fd957>:0 at (wrapper dynamic-method) System.Object:1b37c8f1-1a72-4a48-8432-f868d2c67885 (intptr,intptr) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5572) … 4 more java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
xabrecommented, Nov 24, 2016

FYI: you forgot to await characteristic.WriteAsync(array);

Xamarin.Forms.Device.BeginInvokeOnMainThread should be enough to workaround this issue. If WriteAsync still fails it means that the main thread is not the problem… Usually when, you call Read/Write as a result of the user interacting with the UI it’s already on the main thread…

1reaction
smstuebecommented, Nov 19, 2016

Ye we should do it. Default enabled, and configurable?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ICharacteristic.WriteAsync(byte[]) Error on Android 5.0.1 #115
Caused by: android.runtime.JavaProxyThrowable: Plugin.BLE.Abstractions.Exceptions.CharacteristicReadException: Gatt write characteristic ...
Read more >
How to split and send data >20 bytes for BLE in Xamarin ...
You can try and send the data in multiple chunks each having a maximum size of 20. This example sends the first chunk...
Read more >
xamarin-bluetooth-le
This error is happening extremely often and only on Android. It's easy workaround, just adding a try catch and calling the method again...
Read more >
MBS Bluetooth Plugin Documentation
Function: The zero-based index of the first byte for the read or write request. Notes: You can use the value of this property...
Read more >
https://gitweb.gentoo.org/repo/sync/gentoo.git/pla...
... 2.4.3 3.4.2 4.3.3 4.4.1: A Cross-Platform Benchmark for Android, iOS, Linux, ... dev-java/bcel 6.0_rc3: The Byte Code Engineering Library: analyze, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found