It may be duplicate question of stackoverflow.com/questions/11135680/parse-error-while-installing-downloaded-apk-file, but i didn't find any answers to solve this.
Let me say the issue what i am facing.
I have an application installed in tablet. This application will check for the update whenever it launches. If there is an update it will download the apk and install it automatically. I have used the .NET service as webservice. My .NET service will convert the APK into byte[]array format which is stored in mySQL DB and sent that byte[]Array to my Android Application.
Everything works fine but while installing i am getting
======================================
"PARSER ERROR" Problem parsing a package
======================================
Please don't say check the signature of an apk, everything is okay
Android Code:
SoapPrimitive pResponse = (SoapPrimitive) envelope.getResponse();
byte[] bResponse = Base64.decodeBase64((pResponse.toString().getBytes("UTF-8")));
Struggling alot i have found that the Byte[] response in android is not matching with .net Byte[] as java has signed byte (sbyte -128 to 127)
, while .net has unsigned byte(byte 0 to 255)
eg: In .NET [80,40,2,2,8,0,0,0,12,240,200...........]
In Android [80,40,2,2,8,0,0,0,12,-16,-56...........]
I can use int unsigned = b & 0xFF; to convert that to unsigned byte[] but my problem is my loop will run for 662600 time.
How can i overcome with this issue, Any suggestions from you guys is much helpful for me.