- Home /
2019 Unity Android Exception
I make a plugin for Unity to support Bluetooth Low Energy on Android and iOS.
Version 2019 of Unity now installs its own copy of the Android SDK and NDK, which is awesome.
The thing that I found that surprised me, however, is that now one of my native method calls is throwing and exception. Specifically when I cal setValue on the GATT object to write a characteristic.
In my current version of my plugin I pass a normal C# byte array to my write characteristic method and pass it directly to the setValue call on the Android API.
This now throws an exception where it didn't before.
Here is the exception:
04-23 22:54:49.474 26615 26634 W Unity : AndroidJNIHelper.GetSignature: using Byte parameters is obsolete, use SByte parameters instead
04-23 22:54:49.474 26615 26634 W Unity :
04-23 22:54:49.474 26615 26634 W Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)
04-23 22:54:49.474 26615 26634 W Unity :
04-23 22:54:49.481 26615 26634 W Unity : AndroidJNIHelper: converting Byte array is obsolete, use SByte array instead
04-23 22:54:49.481 26615 26634 W Unity :
04-23 22:54:49.481 26615 26634 W Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)
04-23 22:54:49.481 26615 26634 W Unity :
I did some searches on sbyte and Android and byte and couldn't really find anything related to the native code. What I did find was a lot of information about sbyte and C#.
From the error and my searching it looks like something has changed as it relates to being able to pass a C# byte array to Android native java code. There appears to be some helper in Unity in this AndroidJNIHelper namespace.
The solution to my issue was to not pass in a C# byte array from my C# code to the Android code, but to pass an sbyte array instead.
I would like to better understand where this change occurred. Did something change in Unity or the Android SDK or both?
Your answer
Follow this Question
Related Questions
Sending String of Data through JNI to Android Plugin 1 Answer
Getting byte[] or ByteBuffer[] from native Java 1 Answer
Using AndroidJavaObject.CallStatic to retrieve a return value 0 Answers
[Android] Call .jar function on render thread using JNI 0 Answers
How can I browse files on Android outside of the Unity App folder? 2 Answers