title: Parser Error while installing an APK,downloaded from my own Server
body: <p>It may be duplicate question of <a href="https://stackoverflow.com/questions/11135680/parse-error-while-installing-downloaded-apk-file">stackoverflow.com/questions/11135680/parse-error-while-installing-downloaded-apk-file</a>, but i didn't find any answers to solve this. </p>
  
  <p>Let me say the issue what i am facing.</p>
  
  <p>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.</p>
  
  <p>Everything works fine but while installing i am getting </p>
  
  <p>======================================</p>
  
  <p>"PARSER ERROR" Problem parsing a package</p>
  
  <p>======================================</p>
  
  <p>Please don't say check the signature of an apk, everything is okay  </p>
  
  <p>Android Code:</p>
  
  <pre><code>SoapPrimitive pResponse = (SoapPrimitive) envelope.getResponse();                           
  byte[] bResponse = Base64.decodeBase64((pResponse.toString().getBytes("UTF-8")));
  </code></pre>
  
  <p>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...........]</p>
  
  <p>I can use int unsigned = b &amp; 0xFF; to convert that to unsigned byte[] but my problem is my loop will run for 662600 time.</p>
  
  <p>How can i overcome with this issue, Any suggestions from you guys is much helpful for me.</p>