Where to I place the OBB file to test Android Expansion Pack Files (OBB) on my Nexus 4?

Daniele Segato picture Daniele Segato · Oct 18, 2013 · Viewed 23.1k times · Source

I'm trying to test the Expansion Pack Files (OBB) In Android following the guide here: http://developer.android.com/google/play/expansion-files.html

I'm in the step where I need to test my app on my Nexus 4.

I generated my .obb file with jobb and adb-pushed it in the device in this location:

/mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb

When the app run it doesn't find the file.

Method:

Helpers.doesFileExist(context, fileName, xf.mFileSize, false)

return false for my file.

I debugged and found out it is looking for the file in:

/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb

Specifically this is the path returned by:

Helpers.generateSaveFileName(c, fileName)

The /storage/emulated/0, returned by Environment.getExternalStorageDirectory() doesn't exist browsing the device with adb shell.

But it DOES at runtime, inside the app, I also checked what it contains: it contains almost the same things I found in /mnt/shell/emulated/0, it contains the Android/obb dir, which is empty.

How I found out the path /mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb where I placed my obb file:

$ adb shell
$ ls -ld sdcard
lrwxrwxrwx root     root              2013-10-16 17:34 sdcard -> /storage/emulated/legacy
$ ls -ld /storage/emulated/legacy
lrwxrwxrwx root     root              2013-10-16 17:34 legacy -> /mnt/shell/emulated/0

And inside that I already found the Android/obb directory, empty.

So the question is: where should I put my obb file for it to be in the right position at runtime?

I did everything said there:

  • created a draft application in the Market to get the public key

  • generated a random array of 20 byte (salt)

  • integrated play_licensing/library and play_apk_expansion/download_library

  • wrote my Service / Receiver

  • did the check using the Helpers etc.. exactly like the documentation say.

I suppose everything works but I can't just yet release on Play Store! I need to test locally and I'll have the need to change my obb file pretty often in this initial phase of development.

I can't test on the Emulator because I use 3D and device camera.

Answer

Daniele Segato picture Daniele Segato · Oct 18, 2013

Since Android 4.2 multi users support have been added.

To support that Android mount an emulated disk for each users acting as a sandbox layer around the actual filesystem: this let Android handle gracefully either sharing of files between users either personal files.

Long story short:

/storage/emulated

is the emulated filesystem.

if you enter that directory from adb shell you may see a

/storage/emulated/obb

directory. Sometimes it doesn't show up, for some reason (see below for what to do if this happen)

It's not in /Android/obb but that's the right directory where to place your app package / obb file!

If you don't see that directory try looking in:

/mnt/shell/emulated/obb

You should be able to put your file there.

It will be correctly picked up at runtime ending at the

/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb

path.

I think the Android documentation should explain this.

(I answer my own question because I found out how to solve it while writing it.)