Android Question My first library - signature does not match expected signature

TurboCCC

Member
Licensed User
Hi,

I compiled an existing library "as is" and all worked well. Then, I tried to add one new parameter to newdata to pass the characteristic string being written to B4A.

B4X:
B4A: Sub Peripheral_NewData (DeviceId As String, Descriptor As String, Data() As Byte)

Java event: @Events(values={"Start (Success As Boolean)", "Subscribe (DeviceId As String)", "Unsubscribe (DeviceId As String)", "NewData (DeviceId As String, Descriptor as String, Data() As Byte)"})

Java code:
@Override
            public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
                    BluetoothGattCharacteristic characteristic,
                    boolean preparedWrite, boolean responseNeeded,
                    int offset, byte[] value) {
                if (characteristic.getUuid().equals(charWrite.getUuid())) {
                    ba.raiseEventFromDifferentThread(BlePeripheral3.this, null, 0, eventName + "_newdata", false, new Object[]{device.getAddress(), characteristic.getUuid().toString(), value});
                }
                gattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, value);
            }

This all compiled fine but I'm getting an error at runtime:

Error occurred on line: 0 (BLE_Peripheral)
java.lang.Exception: Sub peripheral_newdata signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject b4a.bbb.ble_peripheral_subs_0._peripheral_newdata(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject,



I read in the forum that this could be a mismatch in parameter types but I believe my parameters are well matched on both sides (string with string). What am I doing wrong?
Thanks.
 

TurboCCC

Member
Licensed User
Solved: I redid the library generation then untick my new library and re-select it. Must have been an inconsistency somewhere. Sorry for the trouble.
 
Upvote 0
Top