I've just finished an app which is about 100MB and I need to use expansion files for the first time.
I've looked through this tutorial http://ankitthakkar90.blogspot.co.uk/2013/01/apk-expansion-files-in-android-with.html, but I don't understand the concept of expansion files and looking for a bit more clarification.
What exactly are the contents of these expansion files? For example my app using alot of images and videos are these what need to go in my expansion files.
If the above is correct does that mean I need to take them out of my project, change my code were I have referenced these resources directly from my drawables and instead reference them from memory?
If both the above are wrong then what exactly goes in the expansion files and what happens to the apk which is already over 50MB.
I'd really appreciate any help explaining this.
1) Expansion files can have any assets that you use in your app (videos,audio,images,text files etc).
2) Yes, your expansion files are extracted inside the external storage of the device.. you should update all your references to get the data from there.
http://developer.android.com/google/play/expansion-files.html
The above link has it all explained (naming to use, how to debug ) etc.
Related
I want to extract Clash of Clans game's images and animations from its android apk file. This is for a personal project and I want to add all characters and buildings in the projects.
I extracted the apk file and found the music but I didn't find any images/drawable assets which resemble any character/building.
There are some files with extension '.sc' and I doubt that they could be the files which I need. But I am not sure what are these and how to get the gif/png out of them? I found those file inside the game's apk at \assets\sc\ path.
Can anyone help me here, please?
Have you had any luck with this? I've also been looking for a way to decompress and came across this repo that decompresses some files, but I can't find a way to decompress the images/icons
https://github.com/amaanq/apk-updater
We are currently working on a Unity Android project that has to have localised mp4 streaming Videos. In order to achieve this I was hoping to put the video files in an expansion obb file, then we can have the same apk and submit it with different obb files according to language.
Unfortunately our application without the videos is still over 50Mb so we need to use the first "main.1.name.obb" for the application.
However we are allowed to also submit a second obb under the name "patch.1.name.obb". However I am having trouble making this and using it. Has anyone tried this with unity before?
The application builds and runs with the first obb file absolutely fine (i.e. the game works without videos) the problem is just in the patch obb creation.
I have tried to create the obb by using a linux zip command with 0% compression then renaming it to a .obb file with no luck. (e.g. patch.1.packname.zip to patch.1.packname.obb)
I have tried to create the obb using jobb tool, and it adds the videos fine but still in game they are not found/played.
The videos are definitely in an "assets" folder inside the obb files made (where I believe streaming assets have to be)
I have fudged the streaming Assets Path ( Application.streamingAssetsPath ) to replace "main" with "patch" and have seen through logcat that it is indeed trying to get the videos from the patch obb file.
(e.g. "jar:file:///[storagelocation]/Android/obb/packname/patch.1.packname.obb!/vid01.mp4 )
Our version code in the AndroidManifest.xml if definitely 1.
Can anyone suggest anything else to try or point out an clear errors I am making in trying to do this?
Let me know any more information you may need to help as well and thanks in advance.
I haven't worked with Unity before, but from my experience I can point out a few things I have found from working with '.obb' files:
Simply renaming the '.zip' file to a '.obb' file will not work. You will need to make a folder named '.obb'. Then add all the needed resource files to this folder and then zip this folder, using 0% compression of course. Make sure that the zipped file contains only the resource files in the root and not a sub folder (the folder you made previously). Now you have a zip file named '.obb.zip'. At this point you can rename the file to '.obb'. Of course, the files may be in a sub folder inside the obb file (the assets folder in your case), but I am not sure about the consequences of this.
In regards to the statement you made concerning the files that are not found after using the jobb tool, this is most likely due to a miss-spelling somewhere or in one of my cases, forgetting to rename the package after copying it from a previous app. I know this seems foolish and maybe insulting (in which case I deeply apologize), but it happens.
This answer is based on my personal experience and may be slightly off center, but here are some links I used:
http://developer.android.com/google/play/expansion-files.html
http://developer.android.com/google/play/publishing/multiple-apks.html
http://developer.android.com/tools/help/jobb.html
My expansion file is 200 Mb. I can't see it viable to pull files out of it in realtime (too slow for my purposes). So, I'm extracting all of them to regular files in other folder.
Now, I want to save some space on the card for my beloved user by avoiding app data duplication.
I have an idea to delete the actual expansion file and replace it with a zero size dummy, to fool Google Play and prevent it from downloading 200Mb again. Would that trick work?
I can't test for that as my app is not published yet.
I have no idea what kind of data they look at in order to redownload the expansion file, but if you don't want to use it as intended I think you'll have an easier time hosting your files and downloading them through your own download mechanism.
I'm using an expansion file (~500mb) that contains videos and more than 20.000 image files.
Which is the best way to manage this file?
For now, i'm loading the ZipFileResource object in my Application class when i check if this file is already downloaded.
One of the uses for this expansion file, is to provide images for a gigapixel view, but it takes a lot of time to load one image, and it should load about 30 images in 200ms.
Before i move this image files to an expansion file, there were in assets folder and worked well.
I'm planning unzip the expansion file at the external storage and remove the obb file, but i don't know if it's a good choice.
Can you tell me some advices?
Thanks in advance.
As far as I understood you, you'll download your mediafiles after you have installed the App. For this I would make it like that, download it and save it to the SD-Card (I would do this in an AsyncTask). Now you save every path of your picture or video into your DB. If you want to get the picture read it out the db and fill your ImageView or whatever. This way is really fast.
I hope I could help you.
safari
I tried to use Zip files as extension files once and I have found that they work very slowly.
OBB files works fast, just as with your regular file system.
I'm planning unzip the expansion file at the external storage and remove the obb file, but i don't know if it's a good choice.
It's bad choise. Google doesn't recommend:
To ensure proper behavior, you must not delete, move, or rename the expansion files.
I want to know that how can I directly access the resources like images, sound files etc. from native code i.e. C++ files. Actually I am looking for any example that could help me to use the asset_manager_jni.h methods.
Looking for suggestions. Thanks in advance.
With Regards,
Atul Prakash Singh
Well, you have access to stdio.h. So if it's in a known place (say on the SD card), you can just use that as a path. And there's lot's of tutorials on the net about hot to use stdio (fopen, fclose, etc).
The issue is that resources you bundle into the apk itself (either in res/raw, or assets), stay inside the apk after install. What's worse is that by default, they will be compressed which makes reading it not feasible. This can be avoided, and the easiest way is to rename the asset to have the .mp3 extension (or there are others). The reason for this is because by default, .mp3 is not compressed, regardless of whether or not it actually is an mp3 file). There are other extensions you can use, and ways to tell the tools not to compress your data if you don't like naming all of your assets with .mp3 at the end.
So, you have a few choices here:
Download your resources from the net on your first run, put them in an unobtrusive place (it's probably best to get that path from the sdk when you do the downloading), and use that.
Store your resources in the apk (remember the .mp3 extension, in the assets folder). On your first run, extract the assets to a folder you have access to (and doesn't annoy the user), and use the resources from there.
(what I do) Store your resources in the apk (.mp3 again), and use the jni to read directly from the apk. Yes, the jni is a bit slow, but you shouldn't be reading from the file system all that much anyway, and certainly not at a performance critical point. Nvidia has some very helpful code you can use, you can find it here, it's in the sample code if I remember. Inside the libs folder are some good general purpose libraries you can use that matches stdio, except it also reads from the apk itself.
Hope it helps.
I did use this trick once :
mv $file lib/lib%${file}.so