如何安装加密APK扩展文件? [英] How to mount encrypted APK expansion files?

查看:536
本文介绍了如何安装加密APK扩展文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图安装扩展的文件是这样的:

I tried to mount expansion files this way:

    final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
    String obbPath = Environment.getExternalStorageDirectory() + "/Android/obb";
    final String obbFilePath = obbPath + "/com.example/main.1.com.example.obb";
    storageManager.mountObb(obbFilePath, "SecretKey", new OnObbStateChangeListener() {
        @Override
        public void onObbStateChange(String path, int state) {
            super.onObbStateChange(path, state);
            if (state == OnObbStateChangeListener.MOUNTED) {
                onObbMounted();
            } else {
                Log.d("##", "Path: " + path + "; state: " + state);
            }
        }
    });

但在运行时我得到国家21:ERROR_COULD_NOT_MOUNT:

But in runtime I'm getting state 21: ERROR_COULD_NOT_MOUNT:

Path: /storage/sdcard0/Android/obb/com.example/main.1.com.example.obb; state: 21

我添加了这一点:

I've added this:

    File f = new File(obbFilePath);
    if (!f.exists()) {
        Log.e("OBB", "FILE NOT FOUND!!!");
    }

和logcat中说,该文件存在。我不知道,为什么我能得到这个国家21?

And logcat says that file exist. I have no idea, why I can get this state 21?

推荐答案

我有同样的问题,我想通AOUT,很多时候错误21 是由Linux的文件casued权限在OBB,而问题是,Android无法访问它,因此 StorageManager 发布错误21 。当您创建.obb文件,更改权限和用户组的文件,是这样的:

I had the same problem, and i figured aout that many times Error 21 is casued by Linux Files Permissions over the obb, and the problem is that Android cannot have access to it so the StorageManager launches Error 21. When you create the .obb file, change permissions and user group to the file, something like:

$chmod 664 <obb-filename>.obb    
$chown user:group <obb-filename>.obb

然后再次尝试,为我工作。

Then try again, worked for me.

这篇关于如何安装加密APK扩展文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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