問題描述
無法在魅族 m3 note 上掛載 .obb 文件(state = 21) (Can't mount .obb file (state = 21) on Meizu m3 note)
我遇到了另一個關於 APK 擴展文件 (.obb‑files) 的奇怪問題。我的擴展文件在我所有的測試設備上安裝都很好:
- Sony Xperia Z1 Compact (API 22)
- Sony Xperia Z1 Ultra (API 22)
- LG Nexus 5X (API 23)
- LG Nexus 4 (API 17)
我用 jobb 創建了加密的 .obb 文件‑utilite:
jobb ‑o obb‑filename ‑d files‑dir ‑k password ‑pn applicationId ‑pv versionCode
在我的應用程序中,我使用以下代碼讀取 .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.");
}
}
並且一切正常。但是關於魅族m3 note(API 22)我們遇到了奇怪的錯誤:“OnObbStateChangeListener::onObbStateChange ‑ 無法裝載 .obb 文件(state = 21)”。
以前,我遇到過這個問題,它是使用另一代 .obb 文件解決。但在這種情況下,它沒有幫助。此外,我嘗試使用 fixed jobb 工俱生成 .obb 文件(https: //github.com/monkey0506/jobbifier.git),但它不起作用。
可能有人知道,出了什麼問題,為什麼有時 .obb 文件在某些情況下不起作用devices?..
UPDATE
此外,我檢查了魅族上未加密的 .obb 文件的安裝情況。有用。
參考解法
方法 1:
I had the same problem, and i figured out that many times Error 21 is caused 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.
方法 2:
I got same problem with Error code 21
i removed the ‑k password
from:
jobb ‑o obb‑filename ‑d files‑dir ‑pn applicationId ‑pv versionCode
and passed null in mountObb
method instead password
storageManager.mountObb(mainObbFile.getAbsolutePath(), null, listener)
I don't know why jobb
not work with password, if someone know please share.
(by Pavel Strelchenko、norcal johnny、Pavel Poley)