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


問題描述

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

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);
            }
        }
    });

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!!!");
    }

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

‑‑‑‑‑

參考解法

方法 1:

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.

(by uncle Lembrachialste)

參考文件

  1. How to mount encrypted APK expansion files? (CC BY‑SA 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)







留言討論