Android的 - 无法打开zip压缩包 [英] Android - failed to open zip archive

查看:1157
本文介绍了Android的 - 无法打开zip压缩包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载apk文件,从网络和存储他到Context.getCacheDir()。我下载文件中的HttpURLConnection - 我不是真正的code问(这是完全工作),所以我没有张贴在这里。我成功启动下载。文件下载到缓存中,然后提示安装 - 但系统无法打开我的APK和分析的写入错误

I am downloading apk file from web and storing him into Context.getCacheDir(). I am downloading file by HttpURLConnection - I am not asking actually on the code (it is fully working), so I am not posting it here. I successfully initiate download. File is downloaded into cache and then is prompted installation - but system cannot open my APK and writes error of analysis.

因此​​问题如下:

03-31 16:48:43.740: INFO/ActivityManager(59): Start proc com.android.packageinstaller for activity com.android.packageinstaller/.PackageInstallerActivity: pid=620 uid=10026 gids={}
03-31 16:48:44.749: WARN/zipro(620): Unable to open zip '/data/data/com.my.app/cache/myApp.apk': Permission denied
03-31 16:48:44.749: DEBUG/asset(620): failed to open Zip archive '/data/data/com.my.app/cache/myApp.apk'
03-31 16:48:44.930: WARN/PackageParser(620): Unable to read AndroidManifest.xml of /data/data/com.my.app/cache/myApp.apk
03-31 16:48:44.930: WARN/PackageParser(620): java.io.FileNotFoundException: AndroidManifest.xml

但问题是 - 我没有权限访问programaticaly /缓存。有什么办法怎么解决呢?我不想使用外部存储作为一个下载目录(当我下载文件到外部存储设备的安装过程的工作),缓存是伟大的,因为该文件将不从文件管理器一般用户访问,这就是我想要的。感谢您的想法。

Problem is - I don't have permission to access programaticaly /cache. Is there any way how to solve it? I don't want to use external storage as a download directory (installation process works when I download file to external storage), cache is great because the file won't be accessible for general user from file manager and that's what I want. Thanks for your thoughts.

这个问题对我来说一直无法解决超过一个月了......

This problem has been for me unsolvable for over a month now...

编辑:仍然无解,我冥思苦想,我发现第一次的事情,这是不可能与Android

Still no solution, I am trying to think that I found 1st thing, that is not possible with Android

EDIT2:我必须一直在寻找坏的 - 我下载的APK是present在高速缓存中......目前还没有权限,允许从该目录安装

I must have been looking bad - my downloaded apk is present in cache... There is still no permission to allow install from that dir?

推荐答案

搭配chmod 666您在您的code安装之前下载的APK文件

chmod 666 on the downloaded apk file before you install it in your code

更多详细信息:

path = your_apk_file_path_in_cache_dir;
permission="666";

try {
    String command = "chmod " + permission + " " + path;
    Runtime runtime = Runtime.getRuntime();
    runtime.exec(command);
} catch (IOException e) {
    e.printStackTrace();
}

这篇关于Android的 - 无法打开zip压缩包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆