简体   繁体   English

从我自己的服务器上下载APK时解析器错误

[英]Parser Error while installing an APK,downloaded from my own Server

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. 它可能是stackoverflow.com/questions/11135680/parse-error-while-installing-downloaded-apk-file的重复问题,但是我没有找到解决此问题的任何答案。

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. 如果有更新,它将下载apk并自动安装。 I have used the .NET service as webservice. 我已经将.NET服务用作Web服务。 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. 我的.NET服务会将APK转换为存储在mySQL DB中的byte [] array格式,并将该byte [] Array发送到我的Android应用程序。

Everything works fine but while installing i am getting 一切正常,但在安装时我正在

====================================== =====================================

"PARSER ERROR" Problem parsing a package “ PARSER ERROR”解析软件包时出现问题

====================================== =====================================

Please don't say check the signature of an apk, everything is okay 请不要说检查apk的签名,一切都还好

Android Code: Android代码:

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...........] 我在挣扎中发现Byte []响应与.net Byte []不匹配,因为java具有带符号的字节(sbyte -128至127),而.net具有无符号的字节(byte 0至255),例如: .NET [80,40,2,2,8,0,0,0,12,240,200 ...........]在Android [80,40,2,2,8,0,0,0 ,12,-16,-56 ...........]

I can use int unsigned = b & 0xFF; 我可以使用int unsigned = b&0xFF; to convert that to unsigned byte[] but my problem is my loop will run for 662600 time. 将其转换为无符号的byte [],但是我的问题是我的循环将运行662600次。

How can i overcome with this issue, Any suggestions from you guys is much helpful for me. 我该如何克服这个问题,你们的任何建议对我都很有帮助。

I had done mistake with installation path where the apk is downloaded.Guys don't bother about the signed and unsigned bytes[] 我在下载apk的安装路径上做错了。您不必担心有符号和无符号字节[]

Steps I had followed for auto updation of an apk from server. 我从服务器自动更新apk遵循的步骤。

  1. Signature of the Previous Version of an apk and the latest/updated apk should be same. apk的先前版本和最新/更新的apk的签名应该相同。

  2. Ensure that the downloaded path and installation path of the apk are same. 确保apk的下载路径和安装路径相同。

NOTE: You can use byte[] or Stream for response from your service 注意:您可以使用byte []或Stream来响应您的服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM