Hi,
I've got the code below. At an certain point StringEncrypt gets called and the last line should execute. However at that point I get the error:
java.lang.Exception: hex string has odd number of characters
at anywheresoftware.b4a.agraham.byteconverter.ByteConverter.HexToBytes(ByteConverter.java:254)
The value of b64str at that moment is: 1204JDS$oftadMin#@2696c99692308015
The strange thing is that it only happens in an released APK. When I run and debug with Debug (rapid) everything goes well.
It also happens on an customers older device (Samsung Xcover). My own Sony Xperia hasn't this problem.
Am I missing something?
I've got the code below. At an certain point StringEncrypt gets called and the last line should execute. However at that point I get the error:
java.lang.Exception: hex string has odd number of characters
at anywheresoftware.b4a.agraham.byteconverter.ByteConverter.HexToBytes(ByteConverter.java:254)
The value of b64str at that moment is: 1204JDS$oftadMin#@2696c99692308015
The strange thing is that it only happens in an released APK. When I run and debug with Debug (rapid) everything goes well.
It also happens on an customers older device (Samsung Xcover). My own Sony Xperia hasn't this problem.
Am I missing something?
B4X:
Sub GetDeviceId As String
Dim r As Reflector
Dim p As Phone
Dim id As String
Dim Api As Int
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
If Api < 9 Then
'Old device
id = p.GetSettings("android_id")
Return id
Else
'New device
id = r.GetStaticField("android.os.Build", "SERIAL")
If id.ToLowerCase = "unknown" Then
id = p.GetSettings("android_id")
End If
Return id
End If
end sub
Sub StringEncrypt As String
Dim text, b64str As String
Dim bConv As ByteConverter
Dim key(0) As Byte
Dim data(0) As Byte
Dim sigdata(0) As Byte
b64str = (1204&"JDS$oftadMin#@"&GetDeviceId)
key = bConv.HexToBytes( b64str )