Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't mount .obb file (state = 21) on Meizu m3 note

I've met with another strange issue with APK Expansion files (.obb-files). My expansion file mounts fine on all my test devices:

  • Sony Xperia Z1 Compact (API 22)
  • Sony Xperia Z1 Ultra (API 22)
  • LG Nexus 5X (API 23)
  • LG Nexus 4 (API 17)

I've created encrypted .obb file with jobb-utilite:

jobb -o obb-filename -d files-dir -k password -pn applicationId -pv versionCode

In my app I read .obb file with following code:

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

And everything works fine. But on Meizu m3 note (API 22) we got strange error: "OnObbStateChangeListener::onObbStateChange - can't mount .obb file (state = 21)".

Previously, I have met with this problem and it was solved with another generation of .obb-file. But in this case it did not help. Also, I've tried to generate .obb file with fixed jobb tool (https://github.com/monkey0506/jobbifier.git), and it doesn't work.

May be anyone knows, what's wrong, why sometimes .obb files doesn't work on some devices?..

UPDATE
Also, I've checked mounting of non-encrypted .obb file on Meizu. It works.

Thanks in advance.

like image 418
Pavel Strelchenko Avatar asked Oct 24 '16 18:10

Pavel Strelchenko


People also ask

How do I open a .OBB file?

You need a suitable software like Android Studio from Google to open an OBB file. Without proper software you will receive a Windows message "How do you want to open this file?" or "Windows cannot open this file" or a similar Mac/iPhone/Android alert.

What is .OBB extension?

An OBB file is an expansion file used by some Android apps distributed using the Google Play online store. It contains data that is not stored in the application's main package (. APK file), such as graphics, media files, and other large program assets. OBB files are often stored in a device's shared storage folder.

What is Android OBB file?

OBB files are used to provide additional file assets for Android applications (such as graphics, sounds and video), separate from an application's APK file. For more information on using expansion files, see APK Expansion Files.


1 Answers

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.

like image 182
norcal johnny Avatar answered Sep 22 '22 20:09

norcal johnny