简体   繁体   中英

Expansion file - can't load .obb from /sdcard/Android/obb/ on Android 4.2

I'm developping the obb integration for the "expansion files". I made it worked in local by copying the .obb file on the sdcard of the device (4.1) but on my 4.2 devices it is not working anymore.

1) On 4.1 tablet: it's working well. I pushed my extension pack file using an adb command on a tablet and then I'm able to find the file and read it :

adb push main.1.mypackage.obb /sdcard/Android/obb/mypackage/
shell@android:/sdcard/Android/obb/mypackage/ $ ls -al
-rw-rw-r-- root     sdcard_rw 20314171 2013-08-05 18:01 main.1.mypackage.obb

2) On 4.2 : the same procedure as above, the file is not "visible", both exists() and canRead() methods on the main activity return false.

adb push main.1.mypackage.obb /sdcard/Android/obb/mypackage/
shell@android:/sdcard/Android/obb/mypackage/ $ ls -al
-rw-rw-r-- root     sdcard_rw 20314171 2013-08-05 18:54 main.1.mypackage.obb

Solution : From there, I investigated using the app "Android File Transfer" and I found that the obb folder is empty from the tool… so it is not the same folders I push the data into…

I uploaded the .obb using the app "Android File Transfer" and then it is working… But in that case I don't know where the file are stored (not on the sdcard, I guess ??)

手动上传文件时有效的Android File Transfer解决方案

So guys, what I need to change on 4.2 for accessing my .obb file? Thanks in advance

Extra informations:

a) I made a basic test to check the file existance using "file.exists() + " canRead=" + file.canRead()" with Environment.getExternalStorageDirectory :

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
            + "/Android/obb/packagename/main.1.packagename.obb");

b) The procedure is scripted so the issue is not coming from a manual mistake (and triple check everythings)

EDIT

c) To sum up :

  • With "adb push" on 4.2 it is working for "normal" data: If I put a folder with images in /sdcard/myfolder/ it is working but not below /sdcard/android/.

  • The Android File Transfer shows a "Android/obb" folder at the root and .obb files are visible from the code in that case but:

  • I cannot confirm it is on the /sdcard from the 'Android File Transfer App', what is disturbing me is that doing an "adb shell ls /sdcard/Android/obb" display that the folder is empty…
  • I cannot use the same script for 4.1 and 4.2, validate the production procedure and use it in dev to save a lot of time with a light apk (and save time on build & deployment time)…

SOLUTION USED INTERNALLY

For < 4.1

adb push main.1.mypackage.obb /sdcard/Android/obb/mypackage/

For >= 4.2

adb push main.1.mypackage.obb /mnt/shell/emulated/obb/mypackage/

Use monitor (Android Debug Monitor) to put expansion files on your device for testing.

My experience with a Nexus 7 (not rooted) using: command line adb vs monitor (Android Debug Monitor)gui:

1) adb push main.1.com.mypackage.obb /sdcard/Android/obb/com.mypackage/main.1.com.mypackage.obb

looked successful. However the app could not find the expansion file, and a file explorer on the device could not display the file. note:the device was not rooted and I could not run adb root.

2) using the monitor gui - start from command line with: ../sdk/tools/monitor Using the monitor gui showed that the /sdcard location actually pointed to several different file links. In order for the app to see the expansion file I had to put the expansion file to the proper linked file location - in my case this was /mnt/shell/emulated/obb/com.mypackage - which adb shell still did not show, however the apps on the device could reach the file.

As I understood, everything works fine when you push file into Android's file system manually. In that case, I believe that problem is with some bug in adb or some misprint. Anyway, you will have to provide Google services integration in order to download APK files from Google servers and you will not have to deal with adb or any other utilities, so I think you don't have to focus on that problem.

not on the sdcard, I guess ??

If it's in /sdcard/ folder - it's on sdcard.

Android put some kind of safe guard in 4.2 for the obb folder(for cracked games and stuff). Take a look for more info in google's android api

I push my backed up obb files form many games and prefer to push them back via adb and I always have to use the full folder structure line so try using

/mnt/sdcard/Android/obb/AppDataFolderNameHere

so for you the code would be;

adb push main.1.mypackage.obb /mnt/sdcard/Android/obb/mypackage/
shell@android://mnt/sdcard/Android/obb//mypackage/ $ ls -al
-rw-rw-r-- root     sdcard_rw 20314171 2013-08-05 18:01 main.1.mypackage.obb

many Linux devices just have the sdcard in the mnt folder event though its a separate storage device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM