How to create OBB files USING jobb tool Android - android

My app has grown to be over 50mb, so I now need to use an expansion file. On searching I came to know that there are different files that can be used as expansion files such as zip, pdf etc. I am trying to put my data in .obb files but I don't know how to create these files and put the data in these files.
Updated
First:
I found out that jobb tool is used to create obb files. But I am confused how this $ jobb -d /temp/assets/ -o my-app-assets.obb -k secret-key -pn com.my.app.package -pv 11 command is run.
I tried to run this ($ jobb -d /temp/assets/ -o my-app-assets.obb -k secret-key -pn com.my.app.package -pv 11 on cmd but my cmd saying jobb is not recognise as internal or external command.
Second:
Which type of files can I put in these obb files? I am thinking layouts, drawable files?

my cmd saying jobb is not recognise as internal or external command
Add /tools to your path or instead of jobb use path/to/sdk/tools/jobb.bat
which type of files are put in these obb files
Big ones. Like drawables, sounds etc. Then, for example, you can use this code to put drawable file into ImageView:
imageView.setImageBitmap(
BitmapFactory.decodeFile(
sm.getMountedObbPath("/path/to/obb/file") +
"path/to/file/in/obb.png")
or, play sound:
mp.setDataSource(AcItem.this,
Uri.fromFile(new File(
sm.getMountedObbPath("/path/to/obb/file") +
"path/to/file/in/obb.png"));
mp.prepare();
mp.start();
As I promised, GitHub link to my obb manager class: https://github.com/uncleLem/AndroidUtils/blob/master/src/io/github/unclelem/androidutils/utils/ObbExpansionsManager.java
I hope it would help.

Just write Like this in command prompt and press enter
C:\>C:\Development\Android\adt-bundle-windows-x86-20140321\sdk\tools\jobb -d C:\
Myworkspace\ImageTargets\assets\ -o Imagetargets.obb -k globe -pn com.ib.globeap
p.activity -pv 200 -v

Related

Running apktool in a bash script

I am trying to write a bash script that decompiles several .apk files using apktool. Each apk file is located in a subdirectory of the sample folder.
#!bin/bash
for item in $(ls samples);
do
for apk in $(ls "samples/$item");
do
echo ./apktool/apktool d "./samples/$item$apk"
$(./apktool/apktool d "./samples/$item$apk")
done
done
When I run the script I get the following output:
./apktool/apktool d ./samples/ADRD/53dc.apk*
Input file (./samples/ADRD/53dc.apk*) was not found or was not readable.
The input file error message is the standard for when apktool cannot find a file. However, if I run the following command in the terminal the apktool will work correctly.
./apktool/apktool d ./samples/ADRD/53dc.apk*
I have changed the permissions of all the files located in the samples folder to rw for all users. I also have tried using sudo with the shell script, but this causes the script to hang. However, when I use sudo with the apktool in the command line it also hangs. Therefore, I am not sure if using sudo with apktool is doable.
Any help is appreciated, thanks.
So it looks like this ls gives you an output with an asterisk * appended at the end of the apk filename, because the file is executable.
for apk in $(ls "samples/$item");
This is not the default behaviour of ls, you are getting this probably because you have aliased ls to ls -F or similar. To bypass the alias, rewrite the line this way:
for apk in $(\ls "samples/$item");
Notice the \ I added there.
BTW, is it normal that an apk file is executable? Perhaps you can remove the executable bit:
find samples -name '*.apk' -exec chmod -x {} \;
Also, possibly your script can be replaced with this one liner:
find samples -name '*.apk' -exec ./apktool/apktool d {} \;
Mind you, this is not exactly the same thing, because it may go deeper than two directories. If you need to limit the depth, that's possible too, see man find

Android - Could not able to get obb file

I have implemented expansion file as per the below link:
a link
When i sign and export application it does not create .obb file and not reduce apk size.
When i run the application it show download failed because resource could not be found.
please help me.
Thanks in advance.
The link you have used its for accessing the .OBB files. You have to manually create them by using the following command.
jobb -d pathToFolder -o fileName.obb -k secret-key -pn packageName -pv 1
For more Info See this

How to create .obb file as main apk expansion file using jobb tool?

I have an apk of 80Mb and so am not able to upload it on google play store. I have googled a lot and found that I have to create .obb file as the main expansion file.
Also I have found that I can create a .obb file using the jobb tool which is inside sdk > tools > jobb.bat but unfortunately it closes just after it starts.
So am I missing something?
i have googled and found that we shold have to make .zip with 0% (No compression) that is mention in http://developer.android.com/google/play/expansion-files.html
Tip: If you're packaging media files into a ZIP, you can use media playback calls on the files with offset and length controls (such as MediaPlayer.setDataSource() and SoundPool.load()) without the need to unpack your ZIP. In order for this to work, you must not perform additional compression on the media files when creating the ZIP packages. For example, when using the zip tool, you should use the -n option to specify the file suffixes that should not be compressed:
zip -n .mp4;.ogg main_expansion media_files
OR How to make 0% compression zip using winrar?
here see the compression method
so we should have to upload this zip in play store.
so you not need to use ZipHelper.java
just simply use
ZipResourceFile expansionFile=null;
try {
expansionFile = APKExpansionSupport.getAPKExpansionZipFile(getApplicationContext(),3,0);
AssetFileDescriptor fd = expansionFile.getAssetFileDescriptor("test.mp4");
MediaPlayer mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mPlayer.setDataSource(fd.getFileDescriptor(),fd.getStartOffset(),fd.getLength());
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Try this
$ jobb -d /temp/assets/ -o new-obb-file.obb -k secret-key -pn com.my.app.package -pv 11
Where
-d <directory> : Set the input directory for creating an OBB file.
-o <filename> : Specify the filename for the OBB file.
-k <key> : Specify a password for encrypting a new OBB file
-pn <package> : Specify the package name for the application that mounts the OBB file, which corresponds to the package value specified in your application's manifest.
-pv <version> : Set the minimum version for the application that can mount the OBB file, which corresponds to the android:versionCode value in your application's manifest.
Try this command.
check following link http://developer.android.com/tools/help/jobb.html
I was able to create the OBB file with below command BUT the problem was it was not extracted in app and stuck at ZipInputStream zis zis.getNextEntry()
/Users/rohit/Library/Android/sdk/tools/bin/jobb -d /Users/rohit/Workspace/code/iam/repo/music' 'files -o main.33.com.aml.iatia.activity.obb -pn com.aml.iatia.activity -pv 33
As a solution, I created using CLI in MAC with below command and it worked very fine.
zip -r main.33.com.aml.iatia.activity.obb music' 'files -x "*/\.*"

XAPK File Validation Failed - APK Expansion Files

I am using the expansion files demo given in the sdks and am placing the obb file on the SD Card at the following location:
/Android/obb/package-name/package-name/main.versioncode.package-name.obb
But i get the following error:
XAPK File Validation Failed
For generating the .obb files this is the procedure i have followed :
1) copy all the images to a folder named main.versioncode.package-name.obb and then zip that file.
2) remove .zip file extension and place it in this /Android/obb/package-name/myobbfile.obb
Is this the correct way of doing it?
An OBB file is an uncompressed ZIP file, so make sure that you zip it without compression.
Every ZIP utility should have some sort of compression level option.
The following screenshot is the open source 7-ZIP gui for Add to Archive with a highlight i added to show where the Compression Level is set to Store.
Another way of doing it would be using jobb
Usage
The syntax for running jobb is as follows:
jobb [-d <directory>][-o <filename>][-pn <package>][-pv <version>] \
[-k <key>][-ov][-dump <filename>][-v][-about]
You can use the jobb tool to create an OBB file or extract the contents of an existing OBB. The following example command creates an OBB file from source files.
$ jobb -d /temp/assets/ -o my-app-assets.obb -k secret-key -pn com.my.app.package -pv 11
This example shows how to dump (extract) the contents of an existing OBB file:
$ jobb -d /temp/obb-output/ -o my-app-assets.obb -k secret-key
Here is how you need to get it done
1) You can put your images in any custom named folder you want. e.g myimages.
2) put all those images in a zip archive, once done adding rename that archive to main.versioncode.package-name.obb
3) Place that .obb file in directory sdcar/Android/obb/package-name/main.versioncode.package-name.obb
Hope it helps

convert odex file to dex file

I would like to covert odex file to dex file. I already pulled framework folder from system. I tried the following command,
java -jar baksmali-2.1.2.jar -d system/framework -x temp.odex
but error was produced - error message is like below.
Error occurred while loading boot class path files. Aborting. org.jf.util.ExceptionWithContext: Cannot locate boot class path file /system/framework/core.jar
at org.jf.dexlib2.analysis.ClassPath.loadClassPathEntry(ClassPath.java:277)
at org.jf.dexlib2.analysis.ClassPath.fromClassPath(ClassPath.java:182)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:67)
at org.jf.baksmali.main.run(main.java:113)
at org.jf.baksmali.main.main(main.java:322)
I could not find "core.jar" in my android system framework folder.
As of 2017-06-09 baksmali has changed. It works like this.
java -jar baksmali-2.2.0.jar d SamsungInCallUI.odex -o SamsungInCallUI
Then assemble the dex file.
java -jar smali-2.2.0.jar ass SamsungInCallUI -o SamsungInCallUI.dex
Try this instead:
java -jar baksmali-2.1.2.jar -c boot.oat -d system/framework/arm/boot.oat -x temp.odex
The specific path to your boot.oat might be different.
Also note that baksmali doesn't yet support deodexing the N preview images.
This worked for me adb pull /system/framework/arm/boot.oat /tmp/framework/boot.oat Placing the apk and the odex file baksmali.jar -x -c boot.oat -d /tmp/framework APKname.odex -o APKname
I'm not sure that I've understood correctly your question (kindly correct me if I'm wrong), but if you are trying to convert an odex to dex, I've already replied to a similar question here: https://reverseengineering.stackexchange.com/questions/12393/reverse-engineering-android-vendor-system-apps/12406#12406
Anyway, to my knowledge you have two chooice:
Follow this guide: http://www.naldotech.com/how-to-deodex-applications-on-android-5-0-lollipop/
Or use oat2dex as pointed out by the user who commented my answer on RE stackexchange.
Good luck
This is an extension of #kakopappa's answer.
Get the latest version of baksmali and smali jar from here and put them in a folder and add this method to your .bash_profile file if you are a mac/linux user.
Get baksmali and smali jar in your computer and assign it to these variables from terminal.
BAKSMALI_JAR_PATH = ""
SMALI_JAR_PATH=""
Note : After editing the value should look something like
BAKSMALI_JAR_PATH = "/Users/rabbit/tools/baksmali-2.2.7.jar"
SMALI_JAR_PATH = "/Users/rabbit/tools/smali-2.2.7.jar"
Copy paste this script in your terminal and restart your terminal. This is a shortcut function which would get added to .bash_profile and you would get it handy.
echo "BAKSMALI_JAR_PATH="$BAKSMALI_JAR_PATH >> ~/.bash_profile
echo "SMALI_JAR_PATH="$SMALI_JAR_PATH >> ~/.bash_profile
echo >>
function odextodex() {
odex_file_name=$1
deassembled_file=${odex_file_name%.odex}
java -jar $BAKSMALI_JAR_PATH d $1 -o $deassembled_file
java -jar $SMALI_JAR_PATH ass $deassembled_file -o $deassembled_file.dex
rm -rf $deassembled_file
}
After doing this type odextodex filename.odex - you should see filename.jar file in your current directory.

Categories

Resources