I just found out about dot42, a C# way to develop native Android Apps.
So my first project way to use some old code for generating CRC8 bytes. I created a new class in the project, copied the code over and tried to use it as normal.
I keep on getting java.lang.VerifyError
??
My class is simple mathematical computation. When I break it out into the main activity as a Public Method it works as expected.
But if I try to use the static class I get that error and I have no idea how to track down what the problem is? I tried adding the various android namespaces, tried making it a normal class to instantiate and even changed it to internal
The method CRC8.Compute("mystring")
does not even go into the compute code (if i put a break point there) It just throws and error right there on the method in MainActivity.cs
What do I have to do to use classes like this using dot42? (I looked at various examples on the site and I cannot pin point anything specific that needs to be done)
namespace dot42Application1
{
public class CRC8
{
static byte[] table = new byte[256];
// x8 + x2 + x + 1
const byte poly = 0x07;
public static string Compute(string ASCI)
{
int crcByte = Convert.ToInt16(ComputeChecksum(System.Text.Encoding.ASCII.GetBytes(ASCI)).ToString());
return crcByte.ToString("000");
}
public static byte ComputeChecksum(byte[] bytes)
{
byte CRCInitialValue = 0xFF;
//Final XOR value 0x00;
//Not revered bytes
//Not reverse CRC berfore final byte
if (bytes != null && bytes.Length > 0)
{
foreach (byte b in bytes)
{
CRCInitialValue = table[CRCInitialValue ^ b];
}
}
return CRCInitialValue;
}
public CRC8()
{
for (int i = 0; i < 256; ++i)
{
int temp = i;
for (int j = 0; j < 8; ++j)
{
if ((temp & 0x80) != 0)
{
temp = (temp << 1) ^ poly;
}
else
{
temp <<= 1;
}
}
table[i] = (byte)temp;
}
}
}
}
Maybe this helps. The stack trace shows...