DumpRom have any bug. it doesn't work well. - General Questions and Answers

Hello,
I tried to extract nk.bin and it was extracted well.
But, dumprom have any bug.
After dumprom util extract files from nk.nb0, it change arm files to mips files.
I extracted files as the following steps;
First, download nk.bin from attached files.
One is arm nk.bin file for wince 5.0 and the other is arm nk.bin file for wince 6.0.
And, download nkbintools files to extract bin image files.
nkbintools also have dumprom util.
1. to dump the content of a nk.bin:
viewbin.exe nk.bin
(write down start and length)
2. cvrtbin -r -a START -w 32 -l LENGTH nk.bin
this command converts the nk.bin to a nk.nb0 (START and LENGTH from the command bevor)
3. dumprom.exe -d dump -v -5 nk.nb0
the content of the nk.bin will be written in the directory "dump". It must exists, otherwise an error occurs.
4. now, see files that is extracted and you will know that they are changed to MIPS files.
Anybody who know why they are changed MIPS files?

Related

32b dream->sapphire script (updated 20th august, new feature!)

So, as the title says a simple bash script to convert a dream rom to a sapphire rom.
To make this work you need unpack / repack boot img utilities from here:
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
testsign.jar from here:
http://forum.xda-developers.com/showpost.php?p=4008431&postcount=15
mkbootimg from here:
http://forum.xda-developers.com/showpost.php?p=3387504&postcount=26
since I'm a nice guy I've included these in the attached zip file.
extract the attached zip file into a folder (warning: make sure there's no spaces in the folder name!!) then run:
Code:
./convert.sh your_dream_rom.zip
this will:
extract the boot.img from the zip
unpack the boot image
rename init.trout.rc to init.sapphire.rc
repack the boot image
put the boot image back into a copy of the dream rom zip
NEW!! in v3: add anything in the 'addin' folder into the zip (see below)
resign the new zip
you'll be left with your_dream_rom-sapphire.zip which should (hopefully) work on the sapphire.
v3: new addin folder. Anything in this folder will be added to the resulting zip, overwriting if needed. So if you want to replace (for example) /system/etc/AudioPara4.csv just put the file in /addin/system/etc and it will automagically be merged in.
Deicist said:
So, as the title says a simple bash script to convert a dream rom to a sapphire rom.
To make this work you need unpack / repack boot img utilities from here:
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
testsign.jar from here:
http://forum.xda-developers.com/showpost.php?p=4008431&postcount=15
since I'm a nice guy I've included these in the attached zip file.
You'll also need to compile the mkbootimg executable that (I think!) comes with the android source.
extract the attached zip file inot a folder then run:
Code:
./convert.sh your_dream_rom.zip
this will:
extract the boot.img from the zip
unpack the boot image
rename init.trout.rc to init.sapphire.rc
repack the boot image
put the boot image back into a copy of the dream rom zip
resign the new zip
you'll be left with your_dream_rom-sapphire.zip which should (hopefully) work on the sapphire.
attached is a zip file containing everything you need except mkbootimg, since that needs to be compiled for your system.
Please note, I don't have a compiled copy of mkbootimg for my system, so I haven't been able to try the full process... but extracting and repacking the zip works, signing seems to work... and it's a pretty simple script so I can't see why it wouldn't work.
Enjoy!
Click to expand...
Click to collapse
Thanks! Do I need a boot.img and wlan.ko for pvt32A if I want it to work?
it won't work for 32a, but I'm sure you can mod the script to add in a new boot.img and radio thingy.
updated initial post with new attachment:
added mkbootimg to zip file
changed script slightly.
in case anyone was wondering, I tried this script on Drizzy's "superlight hero" rom from the dream forum and it worked perfectly.
[email protected]:~$ /home/ubuntu/Desktop/a/convert.sh Personal.zip
unzip: cannot find or open ./Personal.zip, ./Personal.zip.zip or ./Personal.zip.ZIP.
/home/ubuntu/Desktop/a/convert.sh: 3: ./unpack-bootimg.pl: not found
rm: Entfernen von „boot.img“ nicht möglich: No such file or directory
mv: Aufruf von stat für „./boot.img-ramdisk/init.trout.rc“ nicht möglich: No such file or directory
/home/ubuntu/Desktop/a/convert.sh: 6: ./repack-bootimg.pl: not found
cp: Aufruf von stat für „./Personal.zip“ nicht möglich: No such file or directory
zip warning: name not matched: boot.img
zip error: Nothing to do! (update.zip)
/home/ubuntu/Desktop/a/convert.sh: 9: java: not found
rm: Entfernen von „./boot.img-ramdisk“ nicht möglich: No such file or directory
rm: Entfernen von „boot.img-kernel.gz“ nicht möglich: No such file or directory
rm: Entfernen von „boot.img-ramdisk.cpio.gz“ nicht möglich: No such file or directory
rm: Entfernen von „update.zip“ nicht möglich: No such file or directory
Click to expand...
Click to collapse
What do i wrong ... ?
No idea, according to the error message it says it can't find 'Personal.zip'... is that file present in the same directory as 'convert.sh' ?
yes it is ...
can anyone convert this boot.img ... so that i can use on 32b?
you need to actually change directory to the directory containing the utility to run it.
try:
cd /home/ubuntu/Desktop/a/
./convert.sh Personal.zip
is ist possible that it doesn't work because i'm using the live cd now?
now it says
Archive: ./Personal.zip
inflating: ./boot.img
kernel written to ./boot.img-kernel.gz
ramdisk written to ./boot.img-ramdisk.cpio.gz
472 blocks
extracted ramdisk contents to directory ./boot.img-ramdisk/
472 blocks
sh: mkbootimg: not found
repacked boot image written at ./boot.img-ramdisk-repack.img
zip error: Nothing to do! (update.zip)
Click to expand...
Click to collapse
but mkbootimg is in this directory
This is what I end up getting. I ended up using a precompiled binary of mkbootimg for OSX since it didn't work on my Linux box.
./convert.sh NewVision_2.8.zip
Archive: ./NewVision_2.8.zip
inflating: ./boot.img
kernel written to ./boot.img-kernel.gz
ramdisk written to ./boot.img-ramdisk.cpio.gz
extracted ramdisk contents to directory ./boot.img-ramdisk/
usage: cpio -o [-aABcLvVzZ] [-C bytes] [-H format] [-O archive]
[-F archive] < name-list [> archive]
cpio -i [-bBcdfmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]
[-I archive] [-F archive] [pattern...] [< archive]
cpio -p [-adlLmuvV] destination-directory < name-list
repacked boot image written at ./boot.img-ramdisk-repack.img
updating: boot.img (deflated 1%)
Exception in thread "main" java.lang.UnsupportedClassVersionError: testsign (Unsupported major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Hello,
MarcoNieddu said:
extracted ramdisk contents to directory ./boot.img-ramdisk/
472 blocks
sh: mkbootimg: not found
Click to expand...
Click to collapse
You have to modify the script repack-bootimg.pl at line 19 :
replace : system ("mkbootimg ...
by : system ("./mkbootimg ...
Note the ./ before mkbootimg
Scargoll.
Got everything working.
1. Add ./ to the repack script before mkbootimg
2. make sure you have a 32bit OS, as the binary provided was compiled for it. I made an Intrepid machine on my VM server.
3. Use the latest version of Java. Even Karmic Koala Ubuntu doesn't have it. The class file in the jar was compiled with a very recent version of Java, so you'll error out since the jre version isn't equal to or above whats needed. You can simply do "export JAVAHOME=pathtojava" if you don't want to keep that version permanently.
4. Have fun!
Bugfixes:
removes boot.img when script is done
added ./ before mkbootimg (sorry!)
the provided mkbootimg *should* work on a 64bit machine, it does on my 64 bit arch linux box...as with all things linux though, YMMV.
I ve tried to convert a dream rom but it didn't work, does this method can be applied from a windows command shell ?
EDIT: can I take a dream rom, flash it, and push a boot.img from a hero 32B rom ?
EDIT2: Ok now that I have read the name of the topic I understand it wont work in windows. So here's my new question...
Is there a way to adapt this script (or to create something similar) so it works with windows ?
updated with 'addin' feature
ElChouch said:
Is there a way to adapt this script (or to create something similar) so it works with windows ?
Click to expand...
Click to collapse
A windows version would be great!
Nice work Deicist. Thanks for sharing.
some facts:
- i'm running Windows 7 RC (64-bit)
- i installed Cygwin and executed it as administrator
- i browse out to the correct folder where the rom zip file is located
i get the following errors. any suggestions?:
$ ./convert.sh modaco_hero.zip
unzipping...
./convert.sh: line 3: unzip: command not found
unpacking boot image
./convert.sh: ./unpack-bootimg.pl: /usr/bin/perl: bad interpreter: Permission de
nied
moving trout to sapphire
mv: cannot stat `./boot.img-ramdisk/init.trout.rc': No such file or directory
repacking boot image
./convert.sh: ./repack-bootimg.pl: /usr/bin/perl: bad interpreter: Permission de
nied
re-zipping
./convert.sh: line 12: zip: command not found
rm: cannot remove `boot.img': No such file or directory
Addin files found....
./convert.sh: line 18: zip: command not found
Re-signing zip (this may take a while)
tidying up
rm: cannot remove `./boot.img-ramdisk': No such file or directory
rm: cannot remove `boot.img-kernel.gz': No such file or directory
rm: cannot remove `boot.img-ramdisk.cpio.gz': No such file or directory
all done
Make it work on Fedora
Was having problems with this script working at the java part on a FC10 box.
Was able to get it to work by installing java-1.6.0-openjdk:
Code:
$ yum install java-1.6.0-openjdk
just posting that here in case anyone who needs it stumbles by.
Thanks for your great script Deicist
I'm getting this error. What am I doing wrong?
Exception in thread "main" java.lang.NoClassDefFoundError: testsign
at java.lang.Class.initializeClass(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: sun.security.x509.AlgorithmId not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:testsign.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.Class.initializeClass(libgcj.so.90)

How to dump TP2 ROM from Phone

I have successfully dumped the ROM from my Brand New VZW Touch Pro 2 ... Here is how I did it. You will need itsutils to dump the ROM, and imgfstools to extract it.
Dump:
1) List partitions - Should show Part00 to Part03 - pdocread -l
2) Get Part00 address - pdocread -w -d FLASHDR -p Part00 -t -b 0x800 - Find the partition address (displayed as 0x######)
3) Dump Part00 - Use address from step 2 - pdocread -w -d FLASHDR -p Part00 -b 0x800 0 0x###### Part00.raw
4) Repeat steps 2 & 3 for Part01, Part02 and Part03 ... MAKE SURE YOU USE THE CORRECT ADDRESSES
Partitions:
Part00 - Core XIP? (May have something to do with AutoUpdate)
Part01 - XIP
Part02 - OS IMGFS
Part03 - User Storage (TFAT)
Extract XIP (Part00 and Part01 ... You will need bepe's dumpxip.exe from ervius visual kitchen):
1) Make sure there is not an XIP folder (if so, rename it) and run dumpxip Part00.raw
2) Rename XIP folder to XIP_00 (ren XIP XIP_00)
3) Make sure there is not an XIP folder (if so, rename it) and run dumpxip Part01.raw
4) Rename XIP folder to XIP_01 (ren XIP XIP_01)
Extract IMGFS (Part02):
1) imgfstodump Part02.raw - This will create a folder called dump, and extract the contents to it.
View User Storage (Part03):
1) Mount Image using DaemonTools Lite
To rebuild flashable ROM from DUMP (Currently OS Only, No radio or SPL):
1) You need a base_os.nb.payload for your device ... See below for details
2) Convert OS IMGFS (Part02.raw) to nb.payload (new-os.nb.payload) imgfstonb Part02.raw base_os.nb.payload new-os.nb.payload
3) Insert XIP (Part01.raw) into new-os.nb.payload implantxip Part01.raw new-os.nb.payload
4) Merge os-new.nb.payload into os-new.nb nbmerge -kaiser new-os.nb
5) Create os-new.nbh nbhutil, Select "Touch_Pro2" under "Target Device", change RHOD*** to RHOD500, click the ... box next to OS, and select new-os.nb, click Build NBH and select where to save NBH file.
How to get a base os.nb.payload:
1) Download a stock ROM and extract RUU_Signed.nbh
2) Extract RUU_Signed.nbh nbhextract RUU_Signed.nbh - This will list the files extracted ... The one you need is ##_OS.nb ... Copy as os.nb copy ##_OS.nb OS.nb
3) Split OS.nb to OS.nb.payload nbsplit -kaiser OS.nb
4) Create OS.imgfs.bin imgfsfromnb OS.nb.payload OS.imgfs.bin
5) Create empty directory called 'DUMP' (If a DUMP folder exists, rename it) mkdir DUMP
6) Create a blank IMGFS file imgfsfromdump OS.imgfs.bin blank_imgfs.bin
7) Create base_os.nb.payload imgfstonb blank_imgfs.bin OS.nb.payload base_os.nb.payload
Dump SPL and Radio
Does anyone know how to do this?
Oh my god I found the answer on "how to dump a rom from the TP2"!
Could someone rename the topic in something like "official guide" or stick it?
I think it could be useful for a lot of people..
dj13241 said:
How to get a base os.nb.payload:
1) Download a stock ROM and extract RUU_Signed.nbh
2) Extract RUU_Signed.nbh nbhextract RUU_Signed.nbh - This will list the files extracted ... The one you need is ##_OS.nb ... Copy as os.nb copy ##_OS.nb OS.nb
3) Split OS.nb to OS.nb.payload nbsplit -kaiser OS.nb
4) Create OS.imgfs.bin imgfsfromnb OS.nb.payload OS.imgfs.bin
5) Create empty directory called 'DUMP' (If a DUMP folder exists, rename it) mkdir DUMP
6) Create a blank IMGFS file imgfsfromdump OS.imgfs.bin blank_imgfs.bin
7) Create base_os.nb.payload imgfstonb blank_imgfs.bin ##_OS.nb.payload base_os.nb.payload
Click to expand...
Click to collapse
Aloha Man,
- i'm trying to use your tutorial to Dump and Rebuild an HTC ROSE (S740) ROM
- i'm at the point where i've downloaded the RUU_Signed, and folowed the above procedure until step 7
- in step 2, i've replaced ## in ##_OS.nb with 03, witch is the number of the file after nbhextract
- i can't find 03_OS.nb.payload and at step 7, the command spits out and error :
" ImgfsTools 2.1rc2>imgfstonb blank_imgfs.bin 03_OS.nb.payload base_os.nb.payload
ImgfsToNb 2.1rc2
Using bigstorage mode
Input file 03_OS.nb.payload cannot be opened. Exiting "
Should i rename
OS.nb.payload to 03_OS.nb.payload or change the syntax on the command input file accordingly ?
tks again alot for your help !
UrbanWarrior said:
Aloha Man,
- i'm trying to use your tutorial to Dump and Rebuild an HTC ROSE (S740) ROM
- i'm at the point where i've downloaded the RUU_Signed, and folowed the above procedure until step 7
- in step 2, i've replaced ## in ##_OS.nb with 03, witch is the number of the file after nbhextract
- i can't find 03_OS.nb.payload and at step 7, the command spits out and error :
" ImgfsTools 2.1rc2>imgfstonb blank_imgfs.bin 03_OS.nb.payload base_os.nb.payload
ImgfsToNb 2.1rc2
Using bigstorage mode
Input file 03_OS.nb.payload cannot be opened. Exiting "
Should i rename
OS.nb.payload to 03_OS.nb.payload or change the syntax on the command input file accordingly ?
tks again alot for your help !
Click to expand...
Click to collapse
You are correct ... Step 7 should should not have the ##_ ... I have corrected the instructions above in my previous post. The command should be:
Code:
imgfstonb blank_imgfs.bin OS.nb.payload base_os.nb.payload
dj13241 said:
To rebuild flashable ROM from DUMP (Currently OS Only, No radio or SPL):
1) You need a base os.nb.payload for your device ... See below for details
2) Convert OS IMGFS (Part02.raw) to nb.payload (new-os.nb.payload) imgfstonb Part02.raw os.nb.payload new-os.nb.payload
3) Insert XIP (Part01.raw) into new-os.nb.payload implantxip Part01.raw new-os.nb.payload
4) Merge os-new.nb.payload into os-new.nb nbmerge -kaiser os-new.nb
5) Create os-new.nbh nbhutil, Select "Touch_Pro2" under "Target Device", change RHOD*** to RHOD500, click the ... box next to OS, and select new-os.nb, click Build NBH and select where to save NBH file.
How to get a base os.nb.payload:
1) Download a stock ROM and extract RUU_Signed.nbh
2) Extract RUU_Signed.nbh nbhextract RUU_Signed.nbh - This will list the files extracted ... The one you need is ##_OS.nb ... Copy as os.nb copy ##_OS.nb OS.nb
3) Split OS.nb to OS.nb.payload nbsplit -kaiser OS.nb
4) Create OS.imgfs.bin imgfsfromnb OS.nb.payload OS.imgfs.bin
5) Create empty directory called 'DUMP' (If a DUMP folder exists, rename it) mkdir DUMP
6) Create a blank IMGFS file imgfsfromdump OS.imgfs.bin blank_imgfs.bin
7) Create base_os.nb.payload imgfstonb blank_imgfs.bin OS.nb.payload base_os.nb.payload
Click to expand...
Click to collapse
Aloha again,
i need some further clarifications if u are so kind :
- i've properly finished the "How to get a base os.nb.payload" section, so now i have a "base_os.nb.payload" file
- going back to point 2 of the section "To rebuild flashable ROM from DUMP (Currently OS Only, No radio or SPL)", i've succesfully executed points 2 and 3 , but when i go to try point 4 nbmerge spits out the following error :
"NBMerge 2.1rc2
Could not open input file os-new.nb.payload"
My Questions :
- where do u use the "base_os.nb.payload" file that's created at the "How to get a base os.nb.payload" step ? since the file is called "base_os.nb.payload" and in the command syntax description u call it : "base os.nb.payload"
- until point 4 of the "To rebuild flashable ROM from DUMP (Currently OS Only, No radio or SPL)" section in the syntax u use the name "new-os.nb.payload" for the file,
- from point 4 on u use the term "Merge os-new.nb.payload into os-new.nb" -> so os-new.nb.payload , and NBmerge is expecting "Could not open input file os-new.nb.payload" but until point for we've created a file called "new-os.nb.payload"
- shouldn't the syntax for the commands from point 2 thru 4 be what NBMerge is expecting ? meaning "os-new.nb.payload"
thanks again for your help!
When I get home from work today, I will run through the steps and eliminate any errors I find.
UrbanWarrior, I have updated the 'Build a Flashable ROM' section step 2 ... I changed the reference to 'os.nb.payload' to 'base_os.nb.payload' ... Let me know if you run into any other issues.
I was trying the steps for my HTCJade to dump my stock ROM. Things were going smoothly however, the step
"Insert XIP (Part01.raw) into new-os.nb.payload implantxip Part01.raw new-os.nb.payload"
fails with an error "XIP File not Specified!"
I noticed that the mentioned step is not following tha syntax of the command:
Usage: implantxip -XIP <xip.bin> -PAYLOAD <.nb.payload> [-ImgStart <hexvalue>] [
-uldr [tryremove] ] [-PP <MbValue>] [-NoCert]
The command expects "xip.bin" but i am giving the argument as Part01.raw as per the step.
What to do? Can anybody help.
svaym said:
I was trying the steps for my HTCJade to dump my stock ROM. Things were going smoothly however, the step
"Insert XIP (Part01.raw) into new-os.nb.payload implantxip Part01.raw new-os.nb.payload"
fails with an error "XIP File not Specified!"
I noticed that the mentioned step is not following tha syntax of the command:
Usage: implantxip -XIP <xip.bin> -PAYLOAD <.nb.payload> [-ImgStart <hexvalue>] [
-uldr [tryremove] ] [-PP <MbValue>] [-NoCert]
The command expects "xip.bin" but i am giving the argument as Part01.raw as per the step.
What to do? Can anybody help.
Click to expand...
Click to collapse
i had the same problem. i just did "implantxip -XIP Part01.raw -PAYLOAD new-os.nb.payload"

[APP][DEV][GUIDE] Using the Android Java Internal/Hidden API classes

Using Java Reflection with Eclipse ADT to Access Internal/Hidden API classes.
Purpose
We present a way to access all the Internal and Hidden Java packages/classes
in the AOS. To do this we need to both repackage the Android.jar and hack the
Eclipse ADT plugin, to allow using these internal packages.
Posting
==================================================
Do NOT post general questions/requests on how to
do this or that, they will not be answered here.
DO post if you have additional tricks, hacks or
information that can help/benefit this tutorial.
==================================================
Background
There are two reasons one cannot use internal packages. One reason is that, if
you're using Eclipse as your development platform, those packages are
internally blocked in the Eclipse ADT plugin. Second reason is that the normal
development android.jar runtime does not contain those *.class files that
belong to the internal packages.
"There is no easy way to use com.android.internal package (internal API) or
anything marked with @hide attribute (hidden API) without using reflection.
That’s because android.jar file does not contain classes from internal and
hidden API and because of this nobody can reference those classes in compile
time."
Thus we need to first restore the "original" android.jar which will allow us
to use internal and hidden APIs. But the runtime equivalent of Android SDK’s
android.jar file is framework.jar. This file is located in the
/system/framework/ directory of your device. We will extract and use this for
our pleasure.
The general procedure:
A) Grab the "full" framwork.jar from your device
B) extract the class files
C) add them to "full" android.jar ??
D) Hack the Eclipse ADT plugin jar.
Finally, NOTHING would have been possible without the excellent step-by-step
instructions on the devmaze-blog by senior Android developer Ievgenii Nazaruk
(aka. "inazaruk"). THANK YOU Ievgenii!​References
http://stackoverflow.com/questions/...d-sdk-with-hidden-and-internal-apis-available
http://stackoverflow.com/questions/...-state-permission-for-apps-ran-on-gingerbread
http://code.google.com/p/smali/wiki/DeodexInstructions
http://code.google.com/p/adt-addons/
​
The General Procedure
NOTE: All this was performed on Windows Vista with Cygwin.(1) Grab BOOTCLASSPATH from init.rc
Find the line in your init.rc file that reads something like:
Code:
[SIZE=2]export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar[/SIZE]
Extract and reformat the path to:
Code:
[SIZE=2]core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar[/SIZE]
(2) Grab the "framework" from your device
Create a working directory somewhere, let's call it "_framework":
Code:
[SIZE=2]mkdir ./_framework[/SIZE]
[SIZE=2]cd _framework[/SIZE]
Grab all the framework files from your device:
Code:
[SIZE=2]adb pull /system/framework .[/SIZE]
Rename directory if needed.
NOTE-1: From now on I'll assume you know where you are!
NOTE-2: Most GB 2.3.4+ devices uses .odex'ed files,
with name pairs like: <package>.jar and <package>.odex.
These need to be converted.
(3) Use baksmali with (1)
You can also use baksmali with the switch: -d <framwork-dir>.
The general command is something like below, but in windows there may be "wrappers"
that allow you to just type "baksmali" without the "java -jar" prefix and without
the ".jar" post fix. Anyway here is the command I used:
Code:
[SIZE=2]java -Xmx1024m -jar ./../../baksmali.jar -a 10 -c :core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar -x framework.odex[/SIZE]
==> This results in all files put in the "out" sub-directory.
This directory contain 3 sub-directories (for GB 2.3.4):
Code:
[I]android [/I](Hidden APIs)
[I]com [/I](Internal APIs)
[I]javax [/I](Hidden APIs)
NOTE: If you are using Google's own API's, you will probably also need to add
those packages to the path above. (Eg. Email.jar, etc etc ?)
(4) Then use smali to create a dex file from "out" directory
Code:
java -jar smali.jar out
==> creates out.dex from "out" directory.
(5) Run dex2jar on out.dex
Code:
[SIZE=2]./dex2jar.bat out.dex[/SIZE]
==> creates out_dex2jar.jar
(This .jar contain close to 4900 files at 12 MB!)
(6) Rename "out_dex2jar.jar" to "framework-classes.zip"
Code:
[SIZE=2]mv out_dex2jar.jar framework-classes.zip
unzip framework-classes.zip[/SIZE]
(7) Find and copy your Android SDK's android.jar file
Go to: /path/to/android-sdk-windows/platforms/android-X/android.jar
where X is the API level of interest. This obviously have to match the
API level of the files you extracted from your device in: /system/framework .
This .jar file contain more than 5300 files when expanded, but missing all
the internal packages. Our job is to add them back in.
Let's first make a copy that we can use to expand and add files from (6):
Code:
cp android.jar custom-android.zip
unzip custom-android.zip
(8) Add all *.class files from (6) in to (7)
Copy and replace all existing *.class files from framework-classes.zip into
custom-android.zip:
Code:
[SIZE=2]cp -R /path/to/framework-classes/* /path/to/custom-android/.[/SIZE]
The root content of that directory should then look something like this:
Code:
[SIZE=2]android[/SIZE]
[SIZE=2]assets[/SIZE]
[SIZE=2]com[/SIZE]
[SIZE=2]dalvik[/SIZE]
[SIZE=2]java[/SIZE]
[SIZE=2]javax[/SIZE]
[SIZE=2]junit[/SIZE]
[SIZE=2]META-INF[/SIZE]
[SIZE=2]org[/SIZE]
[SIZE=2]res[/SIZE]
[SIZE=2]AndroidManifest.xml[/SIZE]
[SIZE=2]resources.arsc[/SIZE]
(9) Rename directory and create your new "classy-android.jar"
We rename it so not confuse with the original:
Code:
mv custom-android classy-android
zip classy-android
mv classy-android.zip classy-android.jar
IMPORTANT:
Make absolutely sure that the folder structure of your zip archive
is exactly the same as what you intended. To check, unzip the file
and see if it is what you (and eventually Eclipse) would expect.
(For example, if you use 7zip to zip a directory file called "test",
into "test.zip", you may end-up extracting it to ./test/test/... )
(10) Enabling & Restricting Access to classy-android.jar
Instead of just replacing the android.jar with classy-android.jar, we choose
to create a customized Android platform. This way you can enable the Internal
and Hidden API's for those projects requiring them, while other standard
projects doesn't have access to those.
(a) Go to: /path/to/android-sdk-windows/platforms/
and copy the relevant directory (for example):
Code:
cp -R android-10 android-10-internals
(b) Replace android.jar with your classy-android.jar:
Code:
cp classy-android.jar android.jar
("cp" overwrites!)
(c) Edit the build.prop file:
Edit/replace the following lines:
Code:
[SIZE=2]ro.build.version.sdk=10 ==> ro.build.version.sdk=[COLOR=Black][B]-10[/B][/COLOR][/SIZE]
[SIZE=2]ro.build.version.release=2.3.3 ==> ro.build.version.release=2.3.internal[/SIZE]
(11) Customizing the Eclipse ADT
In order to be able to use com.android.internal packages in the Eclipse ADT,
you have to disable the internal protection mechanism of the plugin, that
prevent you to use these libraries. You can see this by right-clicking on your
project package and navigate to:
Code:
[SIZE=2]==> Properties ==> Java Build Path ==> Libraries (tab) [/SIZE]
[SIZE=2]--> Android 2.x.x --> android.jar [/SIZE]
[SIZE=2]--> "Access rules: 1 rule defined": [B][COLOR=Red](X)[/COLOR][/B] [B]Forbidden: com/android/internal/**[/B][/SIZE]
This can not be removed (bug?), even though the interface allows changing, it
never persists after closing the Properties window. So we have to hack it!
The way to do it, is to hexedit the correct java class file and change the
name from "internal" to "internax". First let's find the correct file. The
plugin file is located in the ./eclipse/plugins/ directory, and its name is
something like:
Code:
com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar
(a) make a backup copy of this (with the exact name preserved) in another directory.
(b) make a another copy of this in another directory.
(c) unzip (b) in that directory
Code:
[SIZE=2]cp com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar hacked_adt.zip[/SIZE]
[SIZE=2]unzip hacked_adt.zip[/SIZE]
[SIZE=2]cd hacked_adt[/SIZE]
This is a huge directory system, so forget poking around in it,
just go to the correct sub-directory:
Code:
[SIZE=2]cd ./com/android/ide/eclipse/adt/internal/project/[/SIZE]
Then find the correct file and the approximate string location within that file:
Code:
[SIZE=2]strings.exe -f -4 -t x ./*.class |grep "android\/internal"[/SIZE]
It happens to be in "AndroidClasspathContainerInitializer.class". Now, use a
hexeditor to find and change the string "com/android/internal/**"
to "com/android/internax/**". That will do it!
Now zip-up your hacked jar directory and copy it over the old one.
(Remember that "cp" overwrites without warning!)
Code:
[SIZE=2]zip hacked_adt[/SIZE]
[SIZE=2]cp hacked_adt.zip /path/to/eclipse/plugins/com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar[/SIZE]
You Are Done!
Enjoy your newly hacked Eclipse! ​Errors
If you get any errors;
1. make sure you have zipped up everything properly as warned before.
2. make sure you have included Google API packages in your BOOTCLASSPATH in step (3).
3. Try to "clean-up" the Java by: "Right-Click" ==> Source ==> "Clean Up...".
4. Google them
5. Ignore them
6. Give up. Not! But I can't help you!
If it still doesn't work, try to download inazaruk's pre-compiled set of internal android.jar's from here.
(For android 7,8,10,15.)
​
WIP! <here be dragons2>
For a project using internal package imports, see my thread:
"[TOOL][APP][WIP] Native AT Command Injector"
<here be more dragons>
Following the instructions in posts 1-2 above, may not always work. It is not known to me at this time, why it shouldn't. One theory is that it can have something to do with how Eclipse and Android.jar is packaging their files and the resulting sizes.
This was mentioned in this Stackoverflow post:
"Jar files: why does extracting then compression a jar file create a file of a different size to the original?"
Then reading the man pages for "jar" we can inform ourselves with:
Code:
[SIZE=2] c Creates a new archive file named jarfile (if f is specified) or to
standard output (if f and jarfile are omitted). Add to it the
files and directories specified by inputfiles.
u Updates an existing file jarfile (when f is specified) by adding
to it files and directories specified by inputfiles.
x Extracts files and directories from jarfile (if f is specified) or
standard input (if f and jarfile are omitted). If inputfiles is
specified, only those specified files and directories are
extracted. Otherwise, all files and directories are extracted.
t Lists the table of contents from jarfile (if f is specified) or
standard input (if f and jarfile are omitted). If inputfiles is
specified, only those specified files and directories are listed.
Otherwise, all files and directories are listed.
i Generate index information for the specified jarfile and its
dependent jar files.
[/SIZE]
More info is provided here:
The JAR Overview @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html
The JAR File Specification @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
The JARIndex Spec @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
JAR Tutorial @
http://java.sun.com/docs/books/tutorial/jar/
pack200 Reference Page @
http://java.sun.com/javase/6/docs/technotes/tools/share/pack200.html
Another theory is that it may have something to do with what seem to be, that Google have revoked the the use of MODIFY_PHONE_STATE since Android 2.3, and that this influences the Eclipse behavior, when using and modifying older android.jar's. This was mentioned here and here.
Any help would be very much appreciated!
< bump >
Hi, thanks for the info, I made it using linux and worked really nice, these were the lines that I used, hope be useful.
This is my Android folder at home
Code:
Android/
├── eclipse
├── ndk
├── platforms-internals
├── sdk
└── tools
Start an avd running the desired API to modify in this case API-17
Code:
$ emulator -avd avd_api_17 -no-window &
Get the framework
Code:
$ cd ~/Android/
$ mkdir _framework
$ cd _framework
$ adb -s emulator-5554 pull /system/framework .
Grab BOOTCLASSPATH
Code:
$ adb -s emulator-5554 shell cat init.rc | grep BOOTCLASSPATH > bootclasspath
I didn't have the tools used in this tutorial, so I included the steps for getting them
Decompile with baskmali
Code:
$ cd ~/Android/tools
$ wget https://smali.googlecode.com/files/baksmali-1.4.2.jar
$ cd ~/Android/_framework
$ java -Xmx1024m -jar ../tools/baksmali-1.4.2.jar -a 17 -c core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:telephony-common.jar:mms-common.jar:android.policy.jar:services.jar:apache-xml.jar -x framework.odex
The parameter -a for baksmali refers to the API we are working with.
Generate out.dex with smali
Code:
$ cd ~/Android/tools
$ wget https://smali.googlecode.com/files/smali-1.4.2.jar
$ cd ~/Android/_framework
$ java -jar ../tools/smali-1.4.2.jar out
Get internal and hidden classes using dex2jar
Code:
$ cd ~/Android
$ wget https://dex2jar.googlecode.com/files/dex2jar-0.0.9.15.zip
$ unzip dex2jar-0.0.9.15.zip
$ rm dex2jar-0.0.9.15.zip
$ cd _framework/
$ ../tools/dex2jar-0.0.9.15/d2j-dex2jar.sh out.dex
$ unzip out-dex2jar.jar -d framework-classes
Add these classes to plataform's default android.jar
Code:
$ cd ~/Android
$ unzip sdk/platforms/android-17/android.jar -d custom-android
$ cp -r _framework/framework-classes/* custom-android/
$ rm -r _framework
$ cd custom-android
$ zip -r ../custom-android.jar *
$ cd ..
$ rm -r custom-android
Create new extended platform
Code:
$ cd ~/Android
$ cp -r sdk/platforms/android-17 platforms-internals/android-17-internals
$ mv custom-android.jar platforms-internals/android-17-internals/android.jar
$ vi platforms-internals/android-17-internals/build.prop
ro.build.version.release=4.2.2
ro.build.version.release=4.2.2.internal
$ ln -s ~/Android/platforms-internals/android-17-internals ~/Android/sdk/platforms/android-17-internals
I use a symlink for keep it a little organized
Hack ADT
Code:
$ cd ~/Android
$ unzip eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar -d hacked_adt
Go to right folder
Code:
$ cd hacked_adt/com/android/ide/eclipse/adt/internal/project/
Find file where is our desired string
Code:
$ strings -f -a -t x * | grep "android\/internal"
Edit with an hex editor
Code:
$ bless AndroidClasspathContainerInitializer.class &
Here we change the l for the x.
Replace original file making a backup
Code:
$ cd ~/Android
$ cp eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar.original
$ cd hacked_adt/
$ zip -r ../eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar *
$ cd ..
$ rm -r hacked_adt
This worked for me... thanks E:V:A
I got just one error related to a dropbox class, but i think this is not important... hope that
lenieto3 said:
...Start an avd running the desired API to modify in this case API-17... This worked for me... I got just one error related to a dropbox class, but i think this is not important...
Click to expand...
Click to collapse
Thanks and sorry for late reply. I'm very happy to hear these instructions still works with API-17! Could you also upload your hacked JAR somewhere so that people can save some time when experimenting?
I was just here to check-in and try to bump this thread to see if it is still useful to anyone.
E:V:A said:
Thanks and sorry for late reply. I'm very happy to hear these instructions still works with API-17! Could you also upload your hacked JAR somewhere so that people can save some time when experimenting?
I was just here to check-in and try to bump this thread to see if it is still useful to anyone.
Click to expand...
Click to collapse
ive got access to ActivityManager's hidden methods.
I want to use the removeTask method, but it keeps saying that I dont have the REMOVE_TASKS permissions even though I added it to the manifest (and turned off lint).
Permission Denial: removeTask() from pid=9963, uid=10179 requires android.permission.REMOVE_TASKS
Does someone know if there are any automated tools to do/performs steps 1-9?
I'd like to see a tool to automatically pull (from phone), extract and create a compatible android.jar.
@Mohammad_Adib: Sorry, this is the wrong thread for those type of questions.
see this link stackoverflow.com|questions|30656933|android-system-framework-jar-files

[GUIDE] How to build .apk file from command line

Author: Apriorit (Device Team)
If you don’t want to install a number of programs for building your Android project, this article is for you. You will need only JDK, the Android SDK platform tools and minimum Android platform for building the project using the batch file.
1. Introduction
In this article, I will describe how to use the Android tools for building the .apk file using the command line. As a result, you can use the batch file for building your Android application. I use Windows commands in this article. But you can use the same Android commands and tools and the same program if you are working on Linux OS. The example of the script for Linux OS is included in the sample project, attached to this article.
2. Preparation
You must install Java JDK and Android SDK on the system where you will build your Android application using the Windows command line. The private keystore also must be present.
2.1 Java JDK
You can use Java JDK from Eclipse or download it from this link: oracle(dot)com/technetwork/java/javase/downloads/index.html and then install it.
2.2 Android SDK
Android SDK and its HOWTO document are available here: developer.android.com/sdk/index.html[/url].
The Android SDK Platform-tools, SDK Platform Android 2.2, and API 8 are the minimum that is needed for the test project work.
2.3 Environment Variables
If you want to have a readable batch script and a program without very long file path definitions, you should use the environment variables. I recommend you to define the following ones:
• JAVABIN path to the Java JDK bin folder. For example: C:\Program Files\Java\jdk\bin. This folder must contain the javac.exe and jarsigner.exe files.
• ANDROID-SDK path to the Android SDK folder. For example: C:\Program Files\Andoroid\android-sdk-windows.
2.4 Private Key for Signing
You can read everything about signing, creating private key, and other operations here: developer.android(dot)com/guide/publishing/app-signing.html
In this article, I describe only one important command that will generate my-release-key.keystore:
Code:
%JAVABIN%\keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Specify your info and you will receive the my-release-key.keystore file. You must remember the password. You will need it later. Also, I recommend you to put the keystore file in the same folder as the project. In the example,It is in the keystore folder in the project directory.
2.5 Example Files Structure
You must remember that the dx Android tool requires the full path, which MUST not contain any spaces. So, check the fact, that your project path satisfies the requirement.
The file structure of the example project, which is built using the build.bat file, is the following:
Code:
SecureMessages/
assets/
keystore/
my-release-key.keystore
res/
drawable-hdpi/
icon.png
drawable-ldpi/
icon.png
drawable-mdpi/
icon.png
layout/
main.xml
values/
strings.xml
src/
org/
secure/
sms/
SecureMessagesActivity.java
StringCryptor.java
SmsReceiver.java
AndroidManifest.xml
build.bat // Windows build script
build.sh
// Linux build script
3. Command Sequence
The following commands are for the Windows OS, but you can find the script for the Linux OS project building in the attached sample.
First of all, we must save current path. Then we must change the CD variable to the path to the build.bat file:
Code:
SET PREV_PATH=%CD%
cd /d %0\..
Then, bin and gen old folders should be recreated:
rmdir "bin" /S /Q
rmdir "gen" /S /Q
mkdir "bin"
mkdir "gen"
I add some definitions. They make the batch file readable and easy to update. So, I recommend you the following definitions:
• minimum Android revision;
• the path to aapt Android tool and its arguments for adding files into the existing archive;
• the path to aapt Android tool and its arguments for packing and generating resources;
• the path to dx Android tool;
• the path to javac utility of JDK.
This list of independent definitions can be used for building the majority of Android projects (of course, with the changed Android revision value). For example:
Code:
SET ANDROID_REV=android-8
SET ANDROID_AAPT_ADD="%ANDROID-SDK%\platforms\%ANDROID_REV%\tools\aapt.exe" add
SET ANDROID_AAPT_PACK="%ANDROID-SDK%\platforms\%ANDROID_REV%\tools\aapt.exe" package -v -f -I "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
SET ANDROID_DX="%ANDROID-SDK%\platform-tools\dx.bat" --dex
SET JAVAC="%JAVABIN%\javac.exe" -classpath "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
Also I need the defined variables for my project:
• APP_NAME is the name of application that will be used for the output APK file.
• JAVAC_BUILD and JAVAC are the same commands, but there are path to the sources, generated R class, and output folder in JAVAC_BUILD.
These variables let us change the project name and paths to the sources easier.
Code:
SET APP_NAME=SecureSms
SET JAVAC_BUILD=%JAVAC% -sourcepath "src;gen" -d "bin"
And now, all preparations are finished and the application can be built. The R file will be generated using aapt tool. All resources will be packed into the resources.ap_ file:
Code:
call %ANDROID_AAPT_PACK% -M "AndroidManifest.xml" -A "assets" -S "res" -m -J "gen" -F "bin\resources.ap_"
Android manifest file, res and assets folder are the input data. Aapt will generate the R class and put it into the gen folder. Then, aapt will pack the resource files into the resourses.ap_ file.
Every folder that contains *.java file must be called with javac. In my example, there is only one folder with javac. So, I have only one command line for building sources:
Code:
call %JAVAC_BUILD% src\org\secure\sms\*.java
As you remember, the JAVAC_BUILD command has already contained the arguments that specify the bin folder. The bin folder is an output folder for the compiled sources.
At this moment, the sources have been compiled successfully and they can be packed in the special dex file:
Code:
call %ANDROID_DX% --output="%CD%\bin\classes.dex" %CD%\bin
For the application signing, the resources file must be copied to another file, which will be used for the signing:
Code:
copy "%CD%\bin\resources.ap_" "%CD%\bin\%APP_NAME%.ap_"
The classes.dex file must be added to the new file that has an ap_ extension
Code:
call %ANDROID_AAPT_ADD% "%CD%\bin\%APP_NAME%.ap_" "%CD%\bin\classes.dex"
Now, the ap_ file is a correct apk file. But it is not signed yet and it cannot be installed to the Android device.
The creation of the signed Android application from the *.ap_ file is the following (Output file name must differ from the input file name – in this case the file extension is changed to the *.apk):
Code:
call "%JAVABIN%\jarsigner" -keystore "%CD%\keystore\my-release-key.keystore" -storepass "password" -keypass "password" -signedjar "%CD%\bin\%APP_NAME%.apk" "%CD%\bin\%APP_NAME%.ap_" "alias_name"
And delete temp ap_ file:
Code:
del "bin\%APP_NAME%.ap_"
Finally, let’s return to the start folder and clear local variables:
Code:
:EXIT
cd "%PREV_PATH%"
ENDLOCAL
exit /b %ERRORLEVEL%
To test the example, you must:
• unpack it
• do the steps 2.1-2.5 from the Preparations paragraph
• run the build.bat file
You can download the sample project source at the article official page apriorit(dot)com/our-company/dev-blog/233-how-to-build-apk-file-from-command-line
Please guide me building with Android support libraries and jack without gradle or ant.
Thanks.

[HELP] How to make a binary executable in Ubuntu

Please whosoever reads this post and has got a solution to this please reply as i need a solution desperatly.This is my third post of the same help and till now i have not got any help.Is this is what xda all about????
Click to expand...
Click to collapse
hello,
I am using a virtual box with Ubuntu 16.04 as guest and Windows 10 as host
I have downloaded the binaries such as simg2img img2simg,etc...But whenever i am using the command
Code:
sudo ./simg2img system.img sys.raw
i am getting the error
Code:
[email protected]:/media/htc_desire$ sudo ./simg2img system.img sys.raw
sudo: unable to execute ./simg2img: No such file or directory
I have also tried the command
Code:
sudo chmod +x simg2img
but still i am getting the same error.
Is there any other way to make the binaries executable and is there any other way to extract a raw image of out a spare image and then mount the raw image inorder to obtain the system folder so that i can access files and folders such as apks and jars.
Can anyone please help me how to use the binaries such as simg2img,img2simg,make_ext4fs,etc... relations to extracting a rom in Ubuntu 16.04. I have been trying to get the system folder out of the sparse image since a week but i a unable to do so.And i have a system.img file in the rom folder but i do not know weather its a sparse image or a raw image.So can anyone please tell me how to differentiate between a Sparse image and a Raw image so that i can extract it accordingly.
Are the files in the same directory as your terminal is? If not you can use the CD command to change folders or you can use a file explorer and right click open terminal here, and then try running the above commands. Also right click on the files your executing and go to permissions tab and tick the box that says something along the lines of "allow execution of file" (sorry can't remeber of the top of my head).
Also another you can try is using the mount command to mount the system .img to a directory of your choosing and then modify the files. A general example can be
Code:
mkdir /temp-sys
mount -o loop auto system.img /temp-sys/
Note: don't use that exact code but do some research as that was also off the top of my head. Good luck.

Categories

Resources