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.