無法在魅族 m3 note 上掛載 .obb 文件(state = 21) (Can't mount .obb file (state = 21) on Meizu m3 note)


問題描述

無法在魅族 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 Strelchenkonorcal johnnyPavel Poley)

參考文件

  1. Can't mount .obb file (state = 21) on Meizu m3 note (CC BY‑SA 2.5/3.0/4.0)

#apk-expansion-files #Android






相關問題

從擴展文件播放聲音文件 (Playing sound files from expansion file)

如何掛載加密的APK擴展文件? (How to mount encrypted APK expansion files?)

如何使用jobb工具Android創建OBB文件 (How to create OBB files USING jobb tool Android)

發布不顯示谷歌地圖的 APK 文件 (Release APK file not showing google maps)

PHP - 上傳APK到自己的服務器 (PHP - upload APK to own server)

如果從 Google Play 商店下載 apk 和 obb,則無法在 android 10 設備上訪問 obb 擴展文件 (Cannot reach obb expansion file on android 10 device if apk and obb is downloaded from Google Play store)

APK 擴展文件下載顯示驗證的各種進度 (APK Expansion File Download shows various progress on validation)

APK 擴展文件下載不起作用 (APK Expansion file download doesn´t work)

掛載 .obb 時未調用 OnObbStateChangeListener (OnObbStateChangeListener not called when mounting .obb)

可以掛載未加密的obb但加密錯誤21 (can mount unencrypted obb but with encrypted error 21)

無法在魅族 m3 note 上掛載 .obb 文件(state = 21) (Can't mount .obb file (state = 21) on Meizu m3 note)







留言討論