我遇到了另一个与APK扩展文件(..obb file)有关的奇怪问题。我的扩展文件可以安装在我的所有测试设备上:
我用jobb-utilite创建了加密的.obb文件:
obb-filename jobb -o -d 文件-dir -k 密码E 221E 122
-pnE 223 applicationId E 126-pve 227E 128
versionCode>E229
在我的应用程序中,我用以下代码读取.obb文件:
public void initialize(final Context context) {
final StorageManager storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
final File mainObbFile = getMainObbFile();
final OnObbStateChangeListener listener = new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == OnObbStateChangeListener.MOUNTED) {
// work with obb file
} else {
throw new RuntimeException("OnObbStateChangeListener::onObbStateChange - can't mount .obb file (state = " + state + ").");
}
}
};
final String key = BuildConfig.MAIN_XAPK_KEY;
if (storageManager.isObbMounted(mainObbFile.getAbsolutePath())) {
// work with obb file
} else if (!storageManager.mountObb(mainObbFile.getAbsolutePath(), key, listener)) {
throw new RuntimeException("Can't create listener for mounting .obb file.");
}
}
一切都很好。但是,在Meizu m3注意到 (API 22)上,我们得到了奇怪的错误:"OnObbStateChangeListener::onObbStateChange -无法挂载.obb文件(state = 21)“。
以前,我遇到过这个问题,用另一代的..obb文件解决了这个问题。但在这种情况下,它没有帮助。此外,我还尝试用固定jobb工具(https://github.com/monkey0506/jobbifier.git)生成https://github.com/monkey0506/jobbifier.git文件,但它不起作用。
也许有人知道,出了什么问题,为什么有时.obb文件在某些设备上不能工作?
更新
另外,我还检查了未加密的.obb文件在Meizu上的挂载。它起作用了。
提前谢谢。
发布于 2016-11-03 06:07:35
我也遇到了同样的问题,我发现错误21多次是由Linux对obb的权限引起的,问题是Android无法访问它,所以StorageManager启动了错误21。创建.obb文件时,将权限和用户组更改为该文件,如下所示:
$chmod 664 <obb-filename>.obb
$chown user:group <obb-filename>.obb
然后再试一次,为我工作。
发布于 2018-03-29 19:50:58
我在错误代码21
中遇到了同样的问题,我从以下位置删除了-k password
:
jobb -o obb-filename -d files-dir -pn applicationId -pv versionCode
并在mountObb
方法中传递null而不是密码。
storageManager.mountObb(mainObbFile.getAbsolutePath(), null, listener)
我不知道为什么jobb
不使用密码,如果有人知道请分享。
https://stackoverflow.com/questions/40224768
复制相似问题