so i wanted to use python through my terminal and not sl4a. I went and downloaded pythonforandroid from google. and installed it on my phone. Which is now on the sd card. Inside of the com.googlecode.pythonforandroid folder is the python module, the lib folder with the .so files and the py programs. i cp'd the module to the system/bin/ dir now i need to place the .so files in the correct place.
The error i receive is:
Code:
# python
Link_image[1962]: 31081 could not load needed library 'libpython2.6.so' for 'python' (load_library[1104]: Library 'libpython.6.so' not found)CANNOT LINK EXECUTABLE
#
i recursively cp'd (cp -R) the entire lib
file into system/lib folder on my droid. It still is not working.
What am i doing wrong?
Manually Deodexing (Windows/Linux/OSX)
Let's start first with deodexing manually in order to learn about how the whole process works. Deodexing manually can be very useful if you only want to deodex a couple apks, or if some apks are giving tools such as xUltimate trouble. So here's what you'll need:
Basic knowledge of odex vs. deodex... READ THIS
Smali/baksmali installed correctly (if you are on Linux/OSX you can get the wrapper script as well, otherwise just use the .jars)
Java JRE installed correctly
The apks you want to deodex
ALL of the files in /system/framework from your ROM
This is also an excellent read for understanding the process of deodexing an apk
The first thing we want to do is find the bootclasspath for the ROM you are using. You will have to get the file /init.rc from your phone in some way; if you prefer using root explorer then use root explorer to copy it to your sd card, I prefer using adb. Once you have init.rc on your computer, open it up in a text editor. Search for the line that begins with "export BOOTCLASSPATH" and copy the rest of the line. It should look like this:
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar:/system/framework/kafdex.jar:/system/framework/com.motorola.orange.simauth.jar
The bootclasspath is simply a list of dependencies that the system apps need to run - i.e. jars/apks that contain code that the system apps use. It is necessary to have the correct bootclasspath when deodexing.
Now that we have the bootclasspath we can start to set up for the actual deodexing. All the files listed in the bootclasspath are found in /system/framework, so grab all the jars/apks in /system/framework from your ROM (adb pull them or take them from the flashable zip if available) and put them in a folder named "framework" somewhere that you can remember, such as your desktop or at the root of your hard drive (i.e. C:\framework). We will use the bootclasspath to find all the files in this folder that are needed to deodex the apps properly.
Now we have to modify the bootclasspath in order to get the baksmali command to work correctly. The current bootclasspath that we have is saying that all the frameworks are in the /system/framework folder of your computer, but most of you have the frameworks somewhere like C:\framework or /home/me/framework. So open your text editor again and paste the current bootclasspath. Hopefully your editor will have a find/replace function; if so, just keep replacing all instances of "/system/framework" with the path to your frameworks. For example, this is what it would look like if your frameworks are in C:\framework:
Code:
C:\framework\core.jar:C:\framework\core-junit.jar:C:\framework\bouncycastle.jar:C:\framework\ext.jar:C:\framework\framework.jar:C:\framework\framework-ext.jar:C:\framework\android.policy.jar:C:\framework\services.jar:C:\framework\apache-xml.jar:C:\framework\filterfw.jar:C:\framework\com.motorola.android.frameworks.jar:C:\framework\com.motorola.android.widget.jar:C:\framework\com.motorola.frameworks.core.addon.jar:C:\framework\kafdex.jar:C:\framework\com.motorola.orange.simauth.jar
Finally we are ready to actually deodex the apks. Place the apks and odex's (odexes?) you want to deodex anywhere... your desktop, a folder somewhere, the root of your hard drive... it does not matter. Place the smali/baksmali .jar's in the same directory as the apps you wish to deodex. Open up a command prompt/terminal/etc and "cd" to the directory that the .apk's are in. For example if they are in C:\apps_to_deodex then I would type
Code:
cd C:\apps_to_deodex
The process for deodexing is a little dance like this:
Use baksmali to decompile the .odex file to smali
Use smali to compile the .smali files to a .dex
Use an archive manager (ex. 7zip) to put the newly created .dex file into the original .apk
Delete the old .odex file and all the decompiled smali.
So, let's begin.
BAKSMALI
Since baksmali/smali are .jar's, we will be using java to execute them. The syntax for the baksmali command is something like this:
Code:
java -jar baksmali.jar -a [COLOR="Red"]api_level[/COLOR] -c [COLOR="red"]bootclasspath[/COLOR] -x [COLOR="red"]file.odex[/COLOR]
The -a argument is not necessary with ICS. If you are on GB then you must use "-a 10" in order for it to deodex properly.
The bootclasspath is the bootclasspath that we determined earlier
The file.odex is, of course, the name of the odex file you want to decompile.
So let's say I want to decompile abc.odex, which was built for ICS. The command would be:
Code:
java -jar baksmali.jar -c C:\framework\core.jar:C:\framework\core-junit.jar:C:\framework\bouncycastle.jar:C:\framework\ext.jar:C:\framework\framework.jar:C:\framework\framework-ext.jar:C:\framework\android.policy.jar:C:\framework\services.jar:C:\framework\apache-xml.jar:C:\framework\filterfw.jar:C:\framework\com.motorola.android.frameworks.jar:C:\framework\com.motorola.android.widget.jar:C:\framework\com.motorola.frameworks.core.addon.jar:C:\framework\kafdex.jar:C:\framework\com.motorola.orange.simauth.jar -x abc.odex
This command creates a directory called "out" containing the decompiled odex file.
SMALI
Now that we have "baksmalid" the odex file, we now need to "smali" it to turn the .smali code into the .dex format. The syntax for this command is something like this:
Code:
java -jar smali.jar out -o classes.dex
We are calling the newly generated file "classes.dex" because that is the file that Android looks for in deodexed apks.
When the command completes you will have a file called "classes.dex" sitting in the directory holding all the deodexed apps.
ARCHIVE MANAGER
Hopefully by now you understand the difference between an odexed app and a deodexed app...
Odexed -> abc.apk AND abc.odex
Deodexed -> abc.apk ONLY which contains classes.dex
So, since we have the classes.dex, all we have to do is drag-n-drop it into the respective.apk using an archive manager such as 7zip (Windows). The result is an .apk which contains all the files necessary for it to install and run... it is deodexed.
CLEANUP
If you are going to repeat the process multiple times you will begin to get confused with filenames and everything. Since you now have a fully funtional abc.apk, you can delete:
-The abc.odex file as it is no longe necessary
-The "out" folder created in step 1
-The classes.dex because it is already copied into abc.apk
TROUBLESHOOTING
Sometimes, no matter what you try, you just can not get an app to deodex because it just isn't finding the right dependencies to load. If you come across some troublesome apps, you can use the "-I" argument when baksmaling to force it to decompile:
Code:
java -jar baksmali.jar -a [COLOR="Red"]api_level[/COLOR] -c [COLOR="red"]bootclasspath[/COLOR] -x -I [COLOR="red"]file.odex[/COLOR]
A warning... if you use the -I option on an app that is normally able to deodex fine, you will most likely get force closes and other random errors. Only use -I as a last resort.
For some reason our BOOTCLASSPATH on the ICS leak seems to list some files that don't exist in /system/framework. This means that when you try to baksmali you will get an error about not being able to load class files. If you get this error, look for the .jar that it references, and delete it from the BOOTCLASSPATH and try again. In the end it should look something like this in Windows:
Code:
C:\path_to_frameworks\core.jar:C:\path_to_frameworks\core-junit.jar:C:\path_to_frameworks\bouncycastle.jar:C:\path_to_frameworks\ext.jar:C:\path_to_frameworks\framework.jar:C:\path_to_frameworks\framework-ext.jar:C:\path_to_frameworks\android.policy.jar:C:\path_to_frameworks\services.jar:C:\path_to_frameworks\apache-xml.jar:C:\path_to_frameworks\filterfw.jar:C:\path_to_frameworks\com.motorola.android.frameworks.jar:C:\path_to_frameworks\com.motorola.android.widget.jar:C:\path_to_frameworks\com.motorola.frameworks.core.addon.jar
Thanks alteredlikeness for the tip!
Deodexing Automatically with xUltimate (Windows)
Coming soon...
Hope this helps clear up some questions that you've had... enjoy!
Nice work!
Mods, stickify please?
Sent from my SAMSUNG-SGH-I747 using xda premium
Grrreat! Thank you for putting this together! I swear I dreamed about this last nite...
But, a note on bootclasspath: For ICS, I have run into problems using it directly from the init.rc - we don't physically have all of those jar files in our framework. So, I removed a couple and have not ran into problems since. Here's what I got:
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar
Edit: edited.
alteredlikeness said:
Grrreat! Thank you for putting this together! I swear I dreamed about this last nite...
But, a note on bootclasspath: For ICS, I have run into problems using it directly from the init.rc - we don't physically have all of those jar files in our framework. So, I removed a couple and have not ran into problems since. Here's what I got:
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar
Click to expand...
Click to collapse
Thanks! I haven't manually done anything in ICS so I forgot about that... modified OP
hello i got classes.dex and put it in Bluetooth.apk , i put it on system/app and removed old apk, .odex files but after reboot i can't find bluetooth.odex in system/app , and not working what i changed in apk...
Error when attempting first deodex
I get this error not matter how I do the command in CMD.
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file C
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:218)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:146)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:101)
at org.jf.baksmali.main.main(main.java:308)
I am a noob when it comes to this stuff...do you have any insight on this? Thanks.
jcvermillion
HTC Droid Incredible 4G LTE
Rooted
Unlocked Bootloader
Ready to Deodex the old fashion way.
First: I got this error:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file C
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:218)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:146)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:101)
at org.jf.baksmali.main.main(main.java:308)
Click to expand...
Click to collapse
after writing this
Code:
java -jar baksmali-1.4.2.jar -a 10 -c \framework\core.jar:\framework\bouncycastle.jar:\framework\ext.jar:\framework\framework.jar:\framework\android.policy.jar:\framework\services.jar:\framework\core-junit.jar -x framework.odex
(I am using mac os x)
Second: what should I use to put classes.dex files inside .jar files??
I have the same error and where i must put your solution
"java -jar baksmali-1.4.2.jar -a 10 -c \framework\core.jar:\framework\bouncycastle.jar:\framework\ext.jar:\framework\framework.jar:\framework\android.policy.jar:\framework\services.jar:\framework\core-junit.jar -x framework.odex"
Where i must put this?
Thanks.
Edit: i used this topic to deodex my pre-rooted ROM: http://forum.xda-developers.com/showthread.php?t=2374008
Help-Me Memo.odex Samsung GT-S5360B
Help-me
C:\framework>java -jar baksmali.jar -a 10 -c c:\framework\core.jar:c:\framework\
bouncycastle.jar:c:\framework\ext.jar:c:\framework\framework.jar:c:\framework\an
droid.policy.jar:c:\framework\services.jar:c:\framework\core-junit.jar -x Memo.o
dex
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file c
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.jav
a:237)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:14
5)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.j
ava:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:111)
at org.jf.baksmali.main.main(main.java:293)
anexo: Memo.apk, Memo.odex, init.rc, BOOTCLASSPATH.txt
Anyone got solution for these 'cannot find boot class path in C' error ?
EDIT:FOUND IT!!!
Just copy all framework files in C:/framework and instead of -c use -d
and command should look like
Code:
java -jar baksmali.jar -a [COLOR="Red"]##(api lvl)[/COLOR] -d C:/framework/ -x [COLOR="red"][.odex file][/COLOR]
No need to type the whole bootclasspath he just needs the path to framework folder
Hope it helps
I am trying to deodex telephony-common.jar and telephony-common.odex
I tried first
Code:
java -jar baksmali.jar -x telephony-common.odex
and got
Code:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Landroid/app/Service;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:784)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:668)
at org.jf.dexlib.Code.Analysis.ClassPath.loadClassDef(ClassPath.java:280)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:163)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPathFromOdex(ClassPath.java:110)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:98)
at org.jf.baksmali.main.main(main.java:278)
Error while loading class Landroid/accessibilityservice/AccessibilityService; from file ./framework.zip
Error while loading ClassPath class Landroid/accessibilityservice/AccessibilityService;
then
Code:
java -jar baksmali.jar -c "/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/core.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/core-junit.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/bouncycastle.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/ext.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/framework.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/framework-ext.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/android.policy.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/services.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/apache-xml.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/filterfw.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.android.frameworks.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.android.widget.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.frameworks.core.addon.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/kafdex.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.orange.simauth.jar -x telephony-common.odex
and got
Code:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file /home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework/core.jar
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:237)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:145)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:105)
at org.jf.baksmali.main.main(main.java:278)
GUIDE
What will you Need:
ApkTool
Java JDK/JRE 32 bit
Terminal knowledge
Brain
Instructions
Extract zip folder to anywhere you choose. E.g: C:/android/apktool extracting the files to 'apktool' folder.
3.Now copy the apk to your Apk Tool folder.
2. Open your terminal
Your terminal will look like this...
C:\users\yourname>
Code:
[COLOR="Black"]cd.. → go back
cd.. android → go to this folder[/COLOR]
(Yes, it contains "..")
So you must be in your folder apktool (E.q: C:/android/apktool>)
3. Installing Framework
Code:
apktool if framework-res.apk
(framework-res.apk is only example.. You can type "apktool if SystemUI.apk",...)
4. Decompiling
Code:
apktool d framework-res.apk framework1
(framework-res.apk is apk which you want to decompile and framework1.. You can type "apktool if SystemUI.apk",...)
Now you can enjoy it!
5. Recompiling/Finished Product
Code:
apktool b framework1 framework-res-new.apk
(framework1 is the folder with your edited files and framework-res-new.apk is your new apk file)
You can't use the new apk... You have to take what you did and add it back to the original apk file to proper signature.
Use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "-new" apk and copy them into Original .apk.
Congratulations! You modded .apk!
you can help i know...
Mlopik said:
GUIDE
What will you Need:
ApkTool
Java JDK/JRE 32 bit
Terminal knowledge
Brain
Instructions
Extract zip folder to anywhere you choose. E.g: C:/android/apktool extracting the files to 'apktool' folder.
3.Now copy the apk to your Apk Tool folder.
2. Open your terminal
Your terminal will look like this...
C:\users\yourname>
Code:
[COLOR="Black"]cd.. → go back
cd.. android → go to this folder[/COLOR]
(Yes, it contains "..")
So you must be in your folder apktool (E.q: C:/android/apktool>)
3. Installing Framework
Code:
apktool if framework-res.apk
(framework-res.apk is only example.. You can type "apktool if SystemUI.apk",...)
4. Decompiling
Code:
apktool d framework-res.apk framework1
(framework-res.apk is apk which you want to decompile and framework1.. You can type "apktool if SystemUI.apk",...)
Now you can enjoy it!
5. Recompiling/Finished Product
Code:
apktool b framework1 framework-res-new.apk
(framework1 is the folder with your edited files and framework-res-new.apk is your new apk file)
You can't use the new apk... You have to take what you did and add it back to the original apk file to proper signature.
Use something like 7zip, take the 'resources.arcs' file and any other xml files you edited out of the "-new" apk and copy them into Original .apk.
Congratulations! You modded .apk!
Click to expand...
Click to collapse
Hey boss... can you tell me how to rename a app... i need it badly.. please.and thanks in advance
Hey guys heres a way to extract source code of an apk
I know many of u may know it but still no thread in this section
If its wrong or right or a question only then reply
NOW WHAT IS SOURCE CODE:
A text listing of commands to be compiled or assembled into an executable program
How to extract source code:
Requirements
1. Android-apktool
2. Dex2jar
3. JD-Gui
Procedure
Rename the .apk file you wish to retrieve and change the extension to .zip. Then extract the file that it creates.
Copy the contents of the dex2jar folder to the extracted folder to make it easier for yourself, and run:
dex2jar classes.dex
and copy the resulting “classes.dex.dex2jar.jar” into a new folder.
Open up the Java Decompiler and drag “classes.dex.dex2jar.jar” into the window and then go to File > Save and save the source in a .zip file.
Extract the saved .zip and copy the contents to a new folder somewhere. This will be where we keep your source code.
Now, copy “framework-res.apk” and “yourapk.apk” to the APKTool folder. Then open a command prompt or Terminal window and type:
apktool if framework-res.apk
apktool d
Now just copy the contents of the resulting folder to the same place you copied the contents of “classes.dex.dex2jar.jar” earlier and you have your source code.
Apk source code files
http://db.tt/oqdrcBpk
Now to import this project into eclipse
Go here
Enjoy modifying
Sent by typing by my fingers
Drop Box Link Not Working...please update it
Thanks for the small guide. I've been wondering if there was a way to do this.
Sent from ALCATEL One Touch Fierce
M not Able to Find dex2jar classes.dex
red de0392 said:
M not Able to Find dex2jar classes.dex
Click to expand...
Click to collapse
You have to run it in CMD that "dex2jar classes.dex" is not a file. its a command.
I have built a few web sites but now I'm learning how to build apps. Is there a way to look at the code that is running a particular app on my phone so I can get an idea of how it is put together?
Can I open an app from my phone with Android Studio?
Follow the steps given below.
Procedure to open the source code:
Step 1:
Make a new folder and copy over the .apk file that you want to decode.
Now rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. Now you can access the classes.dex files, etc. At this stage you are able to see drawables but not xml and java files, so continue.
Step 2:
Now extract this .zip file in the same folder (or NEW FOLDER).
Download dex2jar and extract it to the same folder (or NEW FOLDER).
Move the classes.dex file into the dex2jar folder.
Now open command prompt and change directory to that folder (or NEW FOLDER). Then write d2j-dex2jar classes.dex (for mac terminal or ubuntu write ./d2j-dex2jar.sh classes.dex) and press enter. You now have the classes.dex.dex2jar file in the same folder.
Download java decompiler, double click on jd-gui, click on open file, and open classes.dex.dex2jar file from that folder: now you get class files.
Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage you get the java source but the .xml files are still unreadable, so continue.
Step 3:
Now open another new folder
Put in the .apk file which you want to decode
Download the latest version of apktool AND apktool install window (both can be downloaded from the same link) and place them in the same folder
Download framework-res.apk and put it in the same folder (Not all apk file need this file, but it doesn't hurt)
Open a command window
Navigate to the root directory of APKtool and type the following command: apktool if framework-res.apk
apktool d myApp.apk (where myApp.apk denotes the filename that you want to decode)
now you get a file folder in that folder and can easily read the apk's xml files.