如何安装加密APK扩展文件?(How to mount encrypted APK expansio

2019-08-06 22:53发布

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

    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:

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

我已经添加了这一点:

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

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

Answer 1:

我有同样的问题,我想通AOUT很多次Error 21是由Linux的文件权限在OBB堆砌造成的,问题是,Android的不能访问它,因此StorageManager启动Error 21 。 当您创建.obb文件,更改权限和用户组的文件,是这样的:

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

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



文章来源: How to mount encrypted APK expansion files?