Unity Android patch.obb file creation and use - android

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

Related

Is is possible to package non-standard files in APK without assets?

I am trying to package /somewhere/lib/python3.x inside APK's lib folder like jniLibs. But it contains *.py, *.pyc and other files. I have asked another question, but there is no answer. So this is a general question: do you ever used or developed any plugins that embed non-standard files in APK instead of using assets?
How would you access those files? I mean you could put them in the apk, an apk is just a zip file. But the system won't unpack them for you, and at runtime you won't be able to access the apk file itself (installation unzips your file and deletes the apk). You might be able to fool it into doing so by putting it with the jni libs and hoping it doesn't look at extention, but it seem like a bad idea.
However its not uncommon for an app to take its assets and write them to the filesystem on first boot. In fact its fairly common to do this with updatable assets (you'd then just download new versions on top of them, but you can use the old versions to not need an immediate network connection). This would probably work for you. Just make your initial activity a splash screen, and have it do the copy from assets to files in the background while the splash is up.

Extract Clash of Clans images from Android app

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

Developing an Android project with large assets; installing to device always takes a long time

I'm working on developing an Android application in Android Studio. I have large files in the assets folder, so the 'install' step of the code -> build -> install -> run cycle takes a long time, and I mean several minutes (5 to 10).
What's the best way to reduce that time?
The only idea I have is to use smaller assets data while developing.
The thing is the assets don't really change that often.
Are there any other ways to have the assets "pre-installed" so they don't have to be installed over and over again as part of the app (at least just while developing)
The asset folder consists of one large sqlite file, plus a myriad of image and sound files, that all add up to over 500MB.
I found it a nice way to do it using "Expansion packs" and "Opaque Binary Files" as described here:
https://developer.android.com/google/play/expansion-files.html
https://developer.android.com/studio/command-line/jobb.html
Here's how I did it:
1) Move everything from the assets folder to somewhere else.
Of course you are free to keep things in assets, but in my case I can do without them.
2) Use the jobb tool to create an obb file from your assets.
Assuming your package name is me.name.app
jobb -d appAssets -o main.1.me.name.app.obb -pn me.name.app -pv 1
You might have to change -pv depending on your package version.
The naming chosen here main.1.me.name.app.obb is not arbitrary; it's what the Play Store will rename your file to when you upload it. See the File Name section of the docs.
3) Figure out where you should place your obb file. This is the path that Android will place your file in when the app is downloaded from the play store. I haven't deployed it to the play store yet so for all I know there could be some mistake in this step.
The path to the obb is described in the documentation as <shared-storage>/Android/obb/<package-name>/ where <shared-storage> can be obtained from Environment.getExternalStorageDirectory() and package-name is me.name.app as per our example, so the path to the obb would be:
Environment.getExternalStorageDirectory() + "/Android/obb/me.name.app/main.1.me.name.app.obb"
On my Android, the external store seems to be at "/storage/emulated/0/" but I would assume it could be different across devices.
Once you find out where the path should be, place your obb file there.
4) In your app, use StoreManager.mountObb to mount the obb to a new root path. Store this root path in a global object and use it across your application's code.
You have to go through your code and change any part that relies on the AssetsManager and change it to use regular file paths.
Your app (apk) file size is now much smaller but you still get to access your assets.

Using google play expansion files

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.

I want to create a simple APK that only copies its contents to SD card

I'd like to take a few zip files - file1.zip file2.zip file3.zip etc. and create an APK file which contains them and when installed simply copies them to a specified directory on the sd card of the phone.
Can this be done in just a few lines of code? I really appreciate any input. Thank you.
Anything you put in res/raw is available as a resource you can work with once your app is installed. I'm curious why you want to move zip files to the device without having a "real" app to go with them.

Categories

Resources