2013年9月10日星期二

Mobile access to download apk file installation action is error: Anerror occurred while parsing package

Mobile access to download apk file installation action is error: An error occurred while parsing package .
In computer using a browser to download and install directly on the phone is good , but with the mobile phone to access action downloaded file is inconsistent with the original file size , and installation errors TIP: An error occurred while parsing package .
action code is as follows :
public ActionForward execute (ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
URL downUrl = new URL ("/ APPDown / android / HGT.apk");
URLConnection conn = downUrl.openConnection ();
InputStream is = conn.getInputStream ();
BufferedInputStream in = new BufferedInputStream (is);
response.addHeader ("Content-Disposition", "attachment; filename =" + "HGT. apk ");
/ / response.setContentType ("application / vnd.android.package-archive");
response.addHeader ("Content-Type", "application / vnd.android.package-archive");
OutputStream outputStream = response.getOutputStream ();
byte [] data = new byte [1024];
int size = 0;
int l = 0;
while ((l = in.read (data))> 0) {
size + = l;
outputStream.write (data, 0, l);
}
response.addHeader ("Content-Length", size + "");
outputStream.flush ();
outputStream.close ();
in.close ();
is.close ();
return null;
}
files can be downloaded to the phone normally . But the installation fails.
------ Solution ------------------------------------ --------
this APK APK than what non-
What is the phone project
------ Solution -------------------------------- ------------
computer access is normal, mobile access is a problem, another good point phone? May be related to content , capacity and other limitations on ( unfortunately mobile access to some of the details can not see )
------ Solution -------------------- ------------------------
this mobile browser is not what difference does ( check under this item is better ) , I think the most may still limit the differences of resources .
How much of your apk file ? If the change is small enough will not have a problem
------ Solution ----------------------------- ---------------

I also tend to believe that the development up to now is not no difference , the difference should not big , but it is the performance and pc web a difference, indicating there are still differences .

phone down after a different browser to download a file is not the same size ? How much specific size

------ Solution ------------------------------------ --------


is accurate to the byte is also the same? ( Which is exactly the same , the problem would be much easier )

installation error occurs What do
------ Solution ------------------------------ --------------
critical attention to this section :


response.addHeader("Content-Disposition", "attachment;filename=" + "HGT.apk");
        //response.setContentType("application/vnd.android.package-archive");
        response.addHeader("Content-Type", "application/vnd.android.package-archive");


probably the phone that supports this type of environment ministry , leading download exception.
------ Solution -------------------------------- ------------
hard top, in which finally have a bosom friend ! I start phone Huawei G510T8951 months , is this situation , no matter how the phone can not install the APK file , the computer can be in the phone under normal installation , solution ?
------ Solution - -------------------------------------------
hard top, in this finally have a bosom friend ! I start phone Huawei G510T8951 months , is this situation , no matter how the phone can not install the APK file , the computer can be in the phone under normal installation , solution ?
------ Solution - -------------------------------------------
while ((len = in.read (buffer))! = -1)
{
out.write (buffer, 0, buffer.length);
total + = len;
pg.setProgress (total);
Thread.sleep (20); ------------- download when you can let sleep for a while !
}
out.flush ();
in.close (); ----- Note stream shutdown sequence
out.close ();
return file;
------ For reference only ------------------------------ ---------
top of the next post, looking to solve .
------ For reference only -------------------------------------- -


not a mobile phone project, which is written in java me backstage , when the phone asked me when this action will download an installation file to the user's mobile phone.
------ For reference only -------------------------------------- -
their top one !
------ For reference only -------------------------------------- -
nobody actually continue to expect
------ For reference only ------------------------- --------------


likewise for the other phone , click on the downloaded file to install it on an error message: There was a problem parsing package .
but the original file is good, it may be corrupted files . But details unclear. Expect someone pointing.
------ For reference only -------------------------------------- -

simply, it is a problem with mobile downloads

phone to download the details of what ? Is installed in the phone 's browser url to access or direct access to mobile apps , the program , then what kind of procedures.




------ For reference only ---------------------------------- -----

is installed in the phone 's browser url to access
------ For reference only ------------- --------------------------


should be no difference , and I use the phone on multiple browsers for testing , and finally downloaded files are out of this problem , not paper 1.06M. the Internet looking for a long time no information in this regard , but had to post to ask.
------ For reference only -------------------------------------- -
I do not want the top of this post, but my question is not resolved , look prawn Ariadne .
------ For reference only -------------------------------------- -

there are many complex issues bias is likely to be no ready-made answers , we need to find answers to actively communicate with it

http://en.wikipedia.org/wiki/Mobile_browser
have time to first understand the mobile browser characteristics and differences , hoping to find some clues
------ For reference only -------------- -------------------------


modified under way yesterday , and now mobile phone to download the file size with the same size as the original file (1.06mb), but it still occurs during installation error: parse package problems.
------ For reference only -------------------------------------- -


is the same, when you install the phone prompts an error message: There was a problem parsing package
------ For reference only ---------------- -----------------------

no stack information do ? Just one problem parsing package for the analysis that much

You said manual installation is good , but now installed automatically when the installation files and manually when it is consistent, then it is automatically installed programs write their own ?
------ For reference only -------------------------------------- -


No, the installer did not write , this feature I found in the U.S. group net , that is, when the user simply take a mobile phone to scan a two-dimensional code and it will return a corresponding mobile installation file, click on the download is complete after the phone will automatically prompt the user to install .
------ For reference only -------------------------------------- -


I do not understand since it is exactly the same installation file , but also through the phone comes with the installation program to install, how will install fail?
------ For reference only -------------------------------------- -



This is where the problem lies , puzzling in ......
------ For reference only ----------------------- ----------------

which aspect is certainly not the same as , or from known conditions that some of them are wrong , but also a good check .
------ For reference only -------------------------------------- -



the same results .
------ For reference only -------------------------------------- -


downloading is possible only under the down time of installation files at the click of a mistake . Error message just exactly the same as described above .
------ For reference only -------------------------------------- -
look forward statement posted
------ For reference only ------------------------------ ---------
mobile Brush up on March 1 of the package , the situation remains the same , the phone can not be installed under the APK , in addition to problems when parsing package , as well as the software is not installed and so prompt situations < br> ------ For reference only ---------------------------------------


because there are other things in the busy so this abeyance , but the problem still exists there a way upstairs is feasible , and therefore can not bear stickers.
------ For reference only -------------------------------------- -
I Lv , I also order this issue, work until the present. . . Experts expect ah
------ For reference only ----------------------------------- ----
parse error - parse package problems - solutions.
http://blog.chinaunix.net/uid-22985736-id-2977687.html

mainly used openFileOutput ("test.apk", MODE_PRIVATE) to create an output stream caused .
MODE_PRIVATE the file creation mode into MODE_WORLD_READABLE on it.

Reference : http://stackoverflow.com/questions/5503487/android-failed-to-open-zip-archive

------ For reference only ---------------------------------- -----
HttpServletResponse response = ServletActionContext.getResponse ();

/ / download a local file
/ / read the stream
File file = new File (filePath);
InputStream inStream = new FileInputStream (file) ;/ / file storage path
/ / set the output format
response.reset ();
response.setContentType ("application / vnd.android.package-archive");
response.addHeader ("Content-Disposition", "attachment; filename = \" "
+ file.getName () + "\" ");

/ / loop out of the data stream
byte [] b = new byte [100];
int len;
try {
OutputStream ops = response.getOutputStream ();
while ((len = inStream.read (b))> 0) {
ops.write (b, 0, len);
}

if (null! = ops) {
ops.flush ();
ops.close ();
}
if (null! = inStream) {
inStream.close ();
}
return null;
} catch (IOException e) {
/ / e.printStackTrace ();
}
------ For reference only --------------------------------- ------
I also encountered the same problem , can be downloaded using a computer installed properly , but the phone downloaded apk file is only 1K, parsing errors when installing .

没有评论:

发表评论