Things you will need:
- Java SDK -> Download from HERE
- baksmali-1.3.2.jar and smali-1.3.2.jar-> Download from HERE
- Notepad++-> Download from HERE
Step One:
-> Create a folder named "project" on your desktop and put the "baksmali-1.3.2.jar" and "smali-1.3.2.jar" inside;
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Step Two:
-> Copy your ROM to "Project" folder and open it and extract the file "services.jar" from "system/framework";
Step Three:
-> Extract "classes.dex" from "services.jar" (using winrar) to "Project" folder;
Step Four:
-> Decompile "classes.dex" using baksmali.jar
- Open cmd with administrator rights
- Go to "Project" folder (cd "C:/Users/[your username account]/Desktop/Project/")
- Decompile the file entering this on cmd-> java -jar baksmali-1.3.2.jar classes.dex
- A folder named "out" should now be created
- Go to "out\com\android\server" and open "NotificationManagerService" with notepad++
- Add a # at the beggining of the following lines:
line 1933
before:
if-nez v4, :cond_18
Click to expand...
Click to collapse
after:
#if-nez v4, :cond_18
Click to expand...
Click to collapse
line 1983
before:
if-nez v4, :cond_3d
Click to expand...
Click to collapse
after:
#if-nez v4, :cond_3d
Click to expand...
Click to collapse
save the file and close notepad++;
Step Five:
-> Re-compile classes.dex
- Open cmd as administrator rights
- Go to "Project" folder (cd "C:/Users/[your username account]/Desktop/Project/")
- Re-compile the file entering this on cmd-> java -jar smali-1.3.2.jar -o "C:/Users/[your username account]/Desktop/Project/classes_edited.dex" "C:/Users/[your username account]/Desktop/Project/out"
- A file named "classes_edited.dex" should now be created on "Project" folder;
Step Six:
- Delete "classes.dex" (the old one) and change the name of the new one from "classes_edited.dex" to "classes.dex" and delete the "out" folder
- Open "services.jar" (with winrar) and put the "classes.dex" file at root (it will overwritte automatically). You can delete the "classes.dex" file from "Project" folder.
- Open your rom and copy the "services.jar" file to "system/framework" (it will overwritte automatically). You can delete the "services.jar" file from "Project" folder.
Now just flash the rom via cwm and enjoy BLN for sms!
Issues:
If you are expecting issues in cmd when entering-> java (bla bla bla) you have to do this:
Open the start menu, right click on Computer, and click properties. On the lefthand bar, the bottom option should say "Advanced System Settings". Click this, then click Environment Variables.
Find the variable in the BOTTOM box, that says Path, or PATH. Click on this, and click edit. Now, find the path of your JDK, and find the folder called "bin", usually something like
C:\Program Files\Java\jdk1.5.0_11\bin
Click to expand...
Click to collapse
Thx to Prawesome for helping me!
Nice work darknight_jao.A few suggestions for the guide You could add this to the guide in case the guy who is decompiling classes.dex wants to change it around a bit.
Rename baksmali-1.3.2.jar to baksmali and smali-1.3.2.jar to smali for ease of typing Also,to define the name of the output folder,the codes should be changed to:
Code:
java -jar baksmali.jar -o <out name>
To define Java heap size to 512M
Code:
java -jar -Xmx512 baksmali.jar -o out
For viewing command list
Code:
java -jar baksmali.jar
The same goes for smali.jar too
thx man!
darknight_joao said:
thx man!
Click to expand...
Click to collapse
Not a problem
Awesome!
darknight_joao said:
Things you will need:
- Java SDK -> Download from HERE
- baksmali-1.3.2.jar and smali-1.3.2.jar-> Download from HERE
- Notepad++-> Download from HERE
Step One:
-> Create a folder named "project" on your desktop and put the "baksmali-1.3.2.jar" and "smali-1.3.2.jar" inside;
Step Two:
-> Copy your ROM to "Project" folder and open it and extract the file "services.jar" from "system/framework";
Step Three:
-> Extract "classes.dex" from "services.jar" (using winrar) to "Project" folder;
Step Four:
-> Decompile "classes.dex" using baksmali.jar
- Open cmd with administrator rights
- Go to "Project" folder (cd "C:/Users/[your username account]/Desktop/Project/")
- Decompile the file entering this on cmd-> java -jar baksmali-1.3.2.jar classes.dex
- A folder named "out" should now be created
- Go to "out\com\android\server" and open "NotificationManagerService" with notepad++
- Add a # at the beggining of the following lines:
line 1933
before:
after:
line 1983
before:
after:
save the file and close notepad++;
Step Five:
-> Re-compile classes.dex
- Open cmd as administrator rights
- Go to "Project" folder (cd "C:/Users/[your username account]/Desktop/Project/")
- Re-compile the file entering this on cmd-> java -jar smali-1.3.2.jar -o "C:/Users/[your username account]/Desktop/Project/classes_edited.dex" "C:/Users/[your username account]/Desktop/Project/out"
- A file named "classes_edited.dex" should now be created on "Project" folder;
Step Six:
- Delete "classes.dex" (the old one) and change the name of the new one from "classes_edited.dex" to "classes.dex" and delete the "out" folder
- Open "services.jar" (with winrar) and put the "classes.dex" file at root (it will overwritte automatically). You can delete the "classes.dex" file from "Project" folder.
- Open your rom and copy the "services.jar" file to "system/framework" (it will overwritte automatically). You can delete the "services.jar" file from "Project" folder.
Now just flash the rom via cwm and enjoy BLN for sms!
Issues:
If you are expecting issues in cmd when entering-> java (bla bla bla) you have to do this:
Thx to Prawesome for helping me!
Click to expand...
Click to collapse
Thankyou brother
no problem
im glad i could help!
after replacing services.jar, we delete dalvik-cache and data/data, services.jar only files old, for regeneration new
Related
Hi, is it possible to just deodex one apk or do you have to do an entire ROM?
Basically I have a 'Rosie.apk' and 'Rosie.odex', but want to deodex it so I can get to the 'classes.dex' file. Can someone let me know how I might go about this?
Try apktool? Might be Linux only, can't remember sorry.
Sent from my HTC Hero using XDA App
Have successfully done what I wanted now
For info, this is what I did.
Created a new folder called 'system' in c:\android-sdk\tools. Obtained the odexed framework folder and placed that in the system folder. Then created a folder called app in the system folder and placed the Rosie.apk and Rosie.odex inside.
Then via cmd, entered the 'system/app' folder, so for me it was...
c:\android-sdk\tools\system\app
From there I ran the following command to end of that path: baksmali.jar -d ../framework -x Rosie.odex
This produced an out folder will all the decompiled .smali files etc. From there I was able to get to the Launcher.smali that i wanted, but to recompile to a classes.dex file you simply run the following command: smali.jar out
This produces an 'out.dex' that you can rename to 'classes.dex'
I am sure there are other commands that you can use to name files accordingly etc but this is what worked for me for what I wanted, so hopefully it will be of some help to people... if they can understand anything I've written.
jpool81 said:
Have successfully done what I wanted now
For info, this is what I did.
Created a new folder called 'system' in c:\android-sdk\tools. Obtained the odexed framework folder and placed that in the system folder. Then created a folder called app in the system folder and placed the Rosie.apk and Rosie.odex inside.
Then via cmd, entered the 'system/app' folder, so for me it was...
c:\android-sdk\tools\system\app
From there I ran the following command to end of that path: baksmali.jar -d ../framework -x Rosie.odex
This produced an out folder will all the decompiled .smali files etc. From there I was able to get to the Launcher.smali that i wanted, but to recompile to a classes.dex file you simply run the following command: smali.jar out
This produces an 'out.dex' that you can rename to 'classes.dex'
I am sure there are other commands that you can use to name files accordingly etc but this is what worked for me for what I wanted, so hopefully it will be of some help to people... if they can understand anything I've written.
Click to expand...
Click to collapse
If I needed to, how can I recompile back to Rosie.odex (for example). Do I just rename the out.dex file to Rosie.odex or is there another step to get it back to the original version. Here is why I am asking...I wanted to change a few lines in a file in the services.odex file. I deodexed it with the method explained above and now I want to put that file back on my device. Am I going about this the wrong way? Do I need to follow a different process to get it back to the services.odex file?
Thanks.
Could somebody possibly deodex this apk file for me, Ive been at it all day...
I'll be forever in your debit
Code:
http://speedy.sh/4dJ6f/deodex3.rar
I'm trying to implement a Power Menu mod for the SGS4G but I'm running into trouble with Globalactions.smali from Android.Policy.jar. I've been using this guide: http://forum.xda-developers.com/showthread.php?t=811532&highlight=power+menu+mod which was written for the Vibrant and just been adapting it to the SGS4G but I can't even figure out how to adapt it to the Globalactions.smali file.
Could anyone give me a hand? here's the smali file:
http://dl.dropbox.com/u/12235402/GlobalActions.smali
Thanks.
I'm no expert, but I put together these basic instructions for someone else, maybe it will help you....this was specific for the 4n1 power mod
-download patch file: http://forum.xda-developers.com/showpost.php?p=8324212&postcount=2
-deodex android.policy.jar
-open deodexed android.policy.jar w/ 7zip, extract classes.dex
-decompile classes.dex (java -jar baksmali.jar classes.dex)
-make changes per patch file (Baksmali\out\com\android\internal\policy\impl)
-copy folder to smali dir
-compile classes.dex (java -jar smali.jar -o classes.dex out/)
for the icon:
-decompile com.htc.resourses using apktool, (apktool d com.htc.resourses.apk)
-navigate to apktool\com.htc.resources\res\drawable-hdpi & choose an icon, copy it's name
-navigate to apktool\com.htc.resources\res\values\public.xml, search for the icon name
-copy icon hex value, ie... 0x020200d5, omitting the 0x0, making it 20200d5
-open Baksmali\out\com\android\internal\policy\impl\GlobalActions.smali
-search for original icon (20200d9), change to 20200d5
-copy folder to smali dir
-compile classes.dex (java -jar smali.jar -o classes.dex out/)
I have CM7 installed... I know there are settings for screen timeout under display, and CM7 settings allow you to specify the delay for the screen to actually lock. But what about when the screen is locked, you turn it on to check the time and it shuts off after 5 secs. Can this be changed?
Edit: Here's a list of important posts so people don't have to read the entire thread...
Background Info
Step-by-step guide for windows
Allow .jar files to be seen in APK Manager
How-to deODEX android.policy.jar for ODEXed ROMs
How-to for linux/mac(will make a better guide once I finish porting the APK Manager tool from Windows)
Old Stuff:There's not a setting to change the lock screen timeout but I got to looking around and think I found where it can be changed. The stuff I found pointed to android.policy.jar which is located in /system/framework so I adb pulled it and then decoded it using apktool. Some smali files contain hex values of 0x1388 equals 5000 in decimal where 5000ms = 5s. So one of those should be what we want to change. I'm going to try figuring out which one to change, set it to 10s = 10000ms = 0x2710. If it works for me, I can describe how to do it yourself in better detail and/or post a modified android.policy.jar with the timeout you would like.
Edit: I started a thread about this in the Eris dev forum and removed the attached files from here. PM me or post in one of these two threads if you have questions or would like me to modify and send you a custom android.policy.jar
http://forum.xda-developers.com/showthread.php?t=1079844
I successfully increased the default 5s timeout when you wake the phone but don't unlock. If you want to test it out, download one of the attached zip files corresponding to the timeout you would like to have(10s or 30s). Extract android.policy.jar from the zip file and follow either the ADB or Root Explorer or Terminal Emulator instructions below.
If using ADB:
Code:
adb remount
adb shell
cd /system/framework
mv android.policy.jar android.policy.jar.bak
exit
adb push android.policy.jar /system/framework
adb shell
cd /system/framework
chown 0:0 android.policy.jar
chmod 644 android.policy.jar
#reboot to recovery#
#wipe both cache and dalvik-cache#
#reboot#
If using Root Explorer on phone:
mount system as r/w
rename original android.policy.jar in /system/framework to android.policy.jar.bak
move modified android.policy.jar to /system/framework
change owner: owner = 0 - root & group = 0 - root
change permissions: rw-r--r--
#reboot to recovery#
#wipe both cache and dalvik-cache#
#reboot#
Click to expand...
Click to collapse
If using Terminal Emulator on phone:
Code:
mount -o remount,rw /dev/block/mtdblock3 /system
mv /system/framework/android.policy.jar /system/framework/android.policy.jar.bak
mv /PATH/TO/NEW/android.policy.jar /system/framework
cd /system/framework
chown 0:0 android.policy.jar
chmod 644 android.policy.jar
#reboot to recovery#
#wipe both cache and dalvik-cache#
#reboot#
Later tonight or tomorrow I will post a how-to so anyone can make the necessary modifications themselves. That should allow for other devices/ROMs to modify theirs as well since it will be customized to their phone.
I've only tested this on my Eris running GSB v3.1 - Gingerbread 2.3.4 - CM 7.1.0 RC0. Be sure to make a NAND backup and a backup of android.policy.jar as I can't guarantee this will work for you. If you have problems or just want to switch back to the original 5s timeout, replace the modified android.policy.jar with the android.policy.jar backup, wipe cache & dalvik-cache, and reboot or restore from the NAND backup you created.
I'm really surprised no one has brought this idea up before..well glad I had a chance to give you something to dig into and explore some more. I haven't done any editing to system files like this before so I might be posting back with some questions. Thanks for the info..I'll let you know how it goes!
When I plug my phone in it doesnt seem to be going into debugging mode. I have that option checked for it to enable when USB is plugged in but the only icon showing is the USB icon.
I say this because when I run adb devices its not listing my device..also running adb shell it says error: device not found
I havent tried running the adb shell since I flashed to CM7..is there something I need to do differently with this ROM?
thetornado said:
When I plug my phone in it doesnt seem to be going into debugging mode. I have that option checked for it to enable when USB is plugged in but the only icon showing is the USB icon.
I say this because when I run adb devices its not listing my device..also running adb shell it says error: device not found
I havent tried running the adb shell since I flashed to CM7..is there something I need to do differently with this ROM?
Click to expand...
Click to collapse
The debugging notification will only show up if the option for "USB debugging notify" is also checked in Settings->Applications->Development. Not sure why it wouldn't be able to find your phone especially since it sounds like you had it working fine before. What version of adb do you have? I'm using v1.0.26 and never had any problem. You can check the version with the command "adb version". You could also try using adbWireless which would allow you to not have it hooked to your computer with the USB cable.
Scratch that last post..I got it working in ADB Shell
I downloaded the APK tool and moved the files to C:\Windows
Ran this successful: adb pull /system/framework/android.policy.jar
Problem with: apktool d android.policy.jar out - error saying it couldn't find apktool. I went to restart my phone to see if that was an issue and now its hung on the white android screen and wont boot up
Thoughts?
You didn't actually modify anything on the phone right? And didn't push anything to it either? If not, nothing would have changed and it shouldn't be having a problem booting. Try "adb reboot recovery", wipe cache & dalvik-cache then reboot. If you can't run adb commands...pull the battery, put it back in, power it on and hold volume up + power to get into recovery. If something was modified, use adb to revert the modded files back to the originals or restore with a NAND backup if you made one.
Edit: As for apktool not being found, it sounds like apktool is not in your PATH. The Windows folder should be part of your PATH by default. You could check your PATH variable by following these instructions and modify it if needed or you try moving the unpacked apktool files to the same location as the adb command which is most likely /PATH/TO/ANDROID_SDK/platform-tools OR /PATH/TO/ANDROID_SDK/tools
Sorry for the delay..got back to trying this mod. I got an error..
C:\Users\ME\apktool d android.policy.jar out
Unable to access jarfile C:\Windows\\apktool.jar
Did I put these 3 files in the wrong location?
I just saw your comment about putting these files into where adb.exe is located. I moved these files there..also checked my path and its set up for:
Variable: path
Value: C:\android-sdk\platform-tools
The error I got now is: Unable to access jarfile C:\android-sdk\platform-tools\\apktool.jar
I'm not all that familiar with how Windows handles things but something it should be able to find apktool.jar if it's the same directory as apktool.bat. What is the contents of apktool.bat? A workaround would be manually doing the .bat file's job and run "apktool" using this command instead:
Code:
"java -jar /LOCATION/OF/apktool.jar"
Typing that in a cmd window should give you the usage output for apktool. If that works, you could then use that format to decode and build apk/jar files.
I have everything in the folder: C:\android-sdk\platform-tools
Contents of 'apktool.bat':
@echo off
java -jar "%~dp0\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
I am getting this error:
C:\Users\ME>java -jar C:\android-sdk\platform-tools\apktool.jar
Unable to access jarfile C:\android-sdk\platform-tools\apktool.jar
Ok...two more things to try.
Add the location of the java commands to the PATH variable. Probably somewhere like C:\jdk1.6.0_##\bin OR C:\Program Files\Java\jdk1.6.0_##\bin. The PATH variable as a whole would now be something like this: C:\LOCATION\OF\jdk1.6.0_##\bin;C:\WINDOWS\system32;C:\WINDOWS
If that doesn't help: change directory(cd) to C:\android-sdk\platform-tools in the cmd prompt, then run "java -jar apktool.jar"
Sorry it's being such a PITA to just get apktool to run.
1. The location of my Java program is: C:\Program Files\Java - There are 3 folders in there: jdk1.6.0_25, jre1.6.0_22, jre6 - I currently have a user variable 'path' with the value 'C:\android-sdk\platform-tools' - should it be added after this? ..if so, could you explain from what I gave about java what I need to add?
2. Tried cd - same thing..Unable to access jarfile
What does the following command give as output?
Code:
echo %PATH%
I'd set your system environment variable PATH like so:
right-click my computer -> properties -> advanced system settings -> Environment Variables...
under system variables, select Path, and Edit...
add the following(without the quotes) to the end of what's already there: ";C:\Program Files\Java\jdk1.6.0_25\bin;C:\android-sdk\platform-tools;C:\android-sdk\tools"
Also, since you are running Windows...it might make things easier on you to use APK Manager. Here's the thread for it: http://forum.xda-developers.com/showthread.php?t=695701
Here is what I have from the echo %PATH%
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I installed the APK manager..I have it up and running. So I pulled the 'android.policy.jar' - Now what do I do to edit this file?
With all the storms, a power outage, and being busy I'm just now able to get back to you. I'm going to try going through the process using APK Manager on a Windows desktop I have access to. Step-by-step instructions will be in the post below.
Step-by-Step for Windows
You will need the java jdk installed and ADB set up for this to work.
download APK Manager and extract it to you preferred location
this guide will use C:\apk_manager_4.9
run C:\apk_manager_4.9\Script.bat
select option 0 to adb pull
where = /system/framework/android.policy.jar
stored name = android.policy.jar
current project = y
select option 9 to decompile
minimize Script.bat window
use Notepad++(or your preferred editor) to open:
Code:
C:\apk_manager_4.9\projects\android.policy.jar\smali\com\android\internal\policy\KeyguardViewMediator.smali
find ".method public pokeWakelock()V" NOT ".method public pokeWakelock(I)V"
inside the method, find the two lines starting with "const/16 v#" followed by a hex value(0x####)
the second(0x1388=5000ms=5s) is the default timeout unless a hardware keyboard is open, in which case the first(0x2710=10000ms=10s) is used
the values are 16-bit signed integers so the highest either can be set is 0x7FFF=32767ms=32.767s (Your screen will not wake up if set higher)
use this dec->hex convertor to determine the hex equivalent of your desired ms timeout
modify the hex values to your liking, save the file, and close Notepad++
return to the Script.bat window
select option 11 to compile
system apk = y
additional files = n
select option 8 to adb push
where&name = /system/framework/android.policy.jar
select option 24 to quit
open a command prompt to run these commands:
Code:
adb shell chmod 644 /system/framework/android.policy.jar
adb reboot recovery
in recovery,wipe dalvik-cache & cache, then reboot
Done!
All GOOD! Thanks for your hard work on figuring all this out for windows..it really wasn't hard at all once I had the right set of instructions haha
The only thing I've noticed is that the "screen off animation" does not work now - I have checked and unchecked it and its still not working..its really no biggie but just thought I'd say in case you want to play around with this mod more.
thetornado said:
All GOOD! Thanks for your hard work on figuring all this out for windows..it really wasn't hard at all once I had the right set of instructions haha
The only thing I've noticed is that the "screen off animation" does not work now - I have checked and unchecked it and its still not working..its really no biggie but just thought I'd say in case you want to play around with this mod more.
Click to expand...
Click to collapse
I'm glad we finally got it figured out for you. I have the screen animation turned off on my Eris so I didn't notice this broke it. I'll look into it and see if I can figure anything out. The first thing that comes to mind is that the screen off animation could somehow be dependent on the AWAKE_INTERVAL_DEFAULT_MS variable. As I found when first looking at this mod, changing the variable won't actually affect the value wherever it is used since the package is already compiled. So if the animation does use that variable in some way, we'll need to find where that happens and change the value there.
So I decided to write up a little guide on how to modify apk and jar files on the Axon 7 for those of you who do not know how and would like to make some modifications such as the ones in my guides.
Prerequisites
A Windows/Linux/Mac computer
A rooted device with TWRP Recovery
USB cable
ADB installed and USB debugging enabled
Java JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
APKTool: https://ibotpeaches.github.io/Apktool/install/ (Follow all the instructions)
Baksmali: https://bitbucket.org/JesusFreke/smali/downloads/baksmali-2.2.0.jar
7-Zip or another archive manager
1. Install the frameworks to your computer
Open a command window in your working directory and connect your device to your computer with the USB-C cable.
Pull the framework files with
Code:
adb pull /system/framework/framework-res.apk
adb pull /system/framework/framework-zte-res.apk
Install them
Code:
apktool if framework-res.apk
apktool if framework-zte-res.apk
Depending on which ROM you are on you may need to install other frameworks. The above is for the stock ROM.
2. Decompile the apk/jar file.
Pull the apk/jar you want to decompile with
Code:
adb pull path_to_apk_or_jar
Here are paths for some commonly modified apk/jars:
SystemUI: /system/priv-app/SystemUI_ZTE/SystemUI_ZTE.apk
Settings: /system/priv-app/Settings_ZTE/Settings_ZTE.apk
services.jar: /system/framework/services.jar
Decompile the apk with
Code:
apktool d <apk/jar>
If you did everything correctly, a folder should now exist with the name of your apk/jar.
3. Decompile the .odex file
You can skip this step if your apk/jar does not have an .odex associated with it or you only need to modify res and not smali.
Pull the odex file
Code:
adb pull path_to_odex
For example if you want to pull the odex file for SystemUI you would do
Code:
adb pull /system/priv-app/SystemUI_ZTE/oat/arm64/SystemUI_ZTE.odex
Create a folder called "smali" in the directory of your decompiled apk/jar. Then go back to your working directory.
Pull all boot oat files from your device with
Code:
adb pull /system/framework/arm64
Move all the oat files inside the arm64 folder on your PC to your working directory.
Using baksmali, decompile the odex file to smali
Code:
java -jar baksmali.jar deodex -a <api> filename.odex
where api is 23 for Android 6.0, 24 for Android 7.0, and 25 for Android 7.1
A new folder should now be created called "out". Cut and paste the files and folders inside this folder into the "smali" folder you created earlier.
4. Make your modifications.
5. Recompile the apk/jar
From the working directory (not the directory of the decompiled apk/jar) Recompile the apk/jar with
Code:
apktool b name_of_folder
where name_of_folder is the name of the directory of the decompiled apk/jar.
The complied apk/jar should now exist in the "dist" folder in the directory of the decompiled apk/jar.
6. Sign the apk.
Using 7-zip or another archive manager, copy the res folder, resources.arsc file, and the classes.dex file (if you modified smali in steps 3 and 4) from the NEW apk to the ORIGINAL apk.
7. Replace the apk/jar on your device.
Reboot your device into TWRP recovery with
Code:
adb reboot recovery
For user apps: Make sure data is mounted in TWRP's mount menu. If you have encryption turned on you must enter your password otherwise data will not be mounted!
For system apps and framework files: Make sure system is mounted in TWRP's mount menu. Uncheck "Mount system read-only" if it is checked.
Push the ORIGINAL apk/jar to the correct directory on your device
Code:
adb push <apk/jar> path_to_apk_or_jar
Set correct permissions on the apk/jar
Code:
adb shell chmod 0644 path_to_apk_or_jar
If you did step 3, use TWRP's file manager in Advanced<File Manager to navigate to the apk/jar file's directory and delete the existing .oat or .odex file associated with it.
You did it
No go
Hi,
Tried it with the SystemUI_ZTE.apk (and odex) from the 2017G B08 ROM. I ended up with a folder named SystemUI_ZTE. I created a smali folder in that folder and moved the android, com and cn folders (that I got using the "java -jar oat2dex.jar smali SystemUI_ZTE.odex" command) to that smali folder. But when I try the apktool b command I get the following error:
Code:
C:\Users\Blub\ZTE>apktool b SystemUI_ZTE
I: Using Apktool 2.3.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
SystemUI_ZTE\smali\android\support\v17\leanback\app\BackgroundManager.smali[102,4] iput-wide-volatile is an odexed instruction. You cannot reassemble a disassembled odex file unless it has been deodexed.
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file: android/support/v17/leanback/app/BackgroundManager.smali
at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:75)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:59)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:412)
at brut.androlib.Androlib.buildSources(Androlib.java:343)
at brut.androlib.Androlib.build(Androlib.java:299)
at brut.androlib.Androlib.build(Androlib.java:270)
at brut.apktool.Main.cmdBuild(Main.java:224)
at brut.apktool.Main.main(Main.java:75)
Any idea what I am doing wrong?
TIA,
Cheers,
/Cacti
le_cactus said:
Hi,
Tried it with the SystemUI_ZTE.apk (and odex) from the 2017G B08 ROM. I ended up with a folder named SystemUI_ZTE. I created a smali folder in that folder and moved the android, com and cn folders (that I got using the "java -jar oat2dex.jar smali SystemUI_ZTE.odex" command) to that smali folder. But when I try the apktool b command I get the following error:
Any idea what I am doing wrong?
TIA,
Cheers,
/Cacti
Click to expand...
Click to collapse
I updated the OP with a different tool for the odex file. Try it now.
Hi,
Thanks,but "java -jar baksmali-2.2.0.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" gives me this error
Code:
Exception in thread "main" com.beust.jcommander.MissingCommandException: Expected a command, got -a
at com.beust.jcommander.JCommander.parseValues(JCommander.java:725)
at com.beust.jcommander.JCommander.parse(JCommander.java:304)
at com.beust.jcommander.JCommander.parse(JCommander.java:287)
at org.jf.baksmali.Main.main(Main.java:90)
Cheers,
/Cacti
le_cactus said:
Hi,
Thanks,but "java -jar baksmali-2.2.0.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" gives me this error
Cheers,
/Cacti
Click to expand...
Click to collapse
Try it without any arguments: "java -jar baksmali-2.2.0.jar SystemUI_ZTE.odex"
Hi,
The command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex"gives me
Code:
Error occurred while loading class path files. Aborting.
org.jf.dexlib2.analysis.ClassPathResolver$ResolveException: Error while loading oat file boot.oat
at org.jf.dexlib2.analysis.ClassPathResolver.loadEntry(ClassPathResolver.java:250)
at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalClassPathEntry(ClassPathResolver.java:179)
at org.jf.dexlib2.analysis.ClassPathResolver.loadLocalOrDeviceBootClassPathEntry(ClassPathResolver.java:191)
at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:120)
at org.jf.dexlib2.analysis.ClassPathResolver.<init>(ClassPathResolver.java:105)
at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:129)
at org.jf.baksmali.AnalysisArguments.loadClassPathForDexFile(AnalysisArguments.java:86)
at org.jf.baksmali.DisassembleCommand.getOptions(DisassembleCommand.java:203)
at org.jf.baksmali.DeodexCommand.getOptions(DeodexCommand.java:71)
at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:177)
at org.jf.baksmali.Main.main(Main.java:102)
Caused by: org.jf.dexlib2.analysis.ClassPathResolver$NotFoundException: Cannot find dependency boot-core-libart.oat in null
at org.jf.dexlib2.analysis.ClassPathResolver.loadOatDependencies(ClassPathResolver.java:270)
at org.jf.dexlib2.analysis.ClassPathResolver.loadEntry(ClassPathResolver.java:248)
... 10 more
Cheers,
/Cacti
le_cactus said:
Hi,
The command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex"gives me
Cheers,
/Cacti
Click to expand...
Click to collapse
pull boot-core-libart.oat from /system/framework/arm64/boot-core-libart.oat and try again
Muchas gracias
Hi,
Had to pull all the .oat files from the /system/framework/arm64/ folder, only then I didn't get an error any more using the command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex". The "command "java -jar baksmali.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" still gave an error, you might wanna change that in the OP.
Now apktool b SystemUI_ZTE didn't give me any errors anymore. Executed the other steps, and bingo! Everthing seems to work. And byy replacing the charging.ogg, my device charges silently.
Thanks from my wife as she now doesn't wake up when I go to bed (and connect the charger). Many thanks for your patience and your excelent guide! I guess I'll bemodding some more APK's now
Cheers,
/Cacti
le_cactus said:
Hi,
Had to pull all the .oat files from the /system/framework/arm64/ folder, only then I didn't get an error any more using the command "java -jar baksmali.jar deodex -a 25 SystemUI_ZTE.odex". The "command "java -jar baksmali.jar -a 25 -x SystemUI_ZTE.odex -d %CD%" still gave an error, you might wanna change that in the OP.
Now apktool b SystemUI_ZTE didn't give me any errors anymore. Executed the other steps, and bingo! Everthing seems to work. And byy replacing the charging.ogg, my device charges silently.
Thanks from my wife as she now doesn't wake up when I go to bed (and connect the charger). Many thanks for your patience and your excelent guide! I guess I'll bemodding some more APK's now
Cheers,
/Cacti
Click to expand...
Click to collapse
Great! I'll add that to the OP! Thanks for helping me out!
Updated the OP with a new signing method that should fix boot hang issues with some apks (aka Settings_ZTE)
bkores said:
Updated the OP with a new signing method that should fix boot hang issues with some apks (aka Settings_ZTE)
Click to expand...
Click to collapse
IMO it was just the same as your previous method (under 5.)was saying : move META-INF ( and manifest but not necessary imo) from original apk into the new apk (in dist folder).
Now you're saying : put res, resources and classes from new apk into new apk...that's just the same, no ? Only more files to move imo.
Since res, resources and classes are indeed changing by compile, wouldn't it be better by just saying : put META-INF from original apk into new apk, like you first wrote in OP ? Easier no ?
ALSO : under 6. you say : Open a command window in the "dist" folder and push the ORIGINAL apk/jar to the correct directory on your device
Shouldn't that be : push ORIGINAL (since you copied files under 5 from NEW(in "dist") to ORIGINAL(in working folder) ) FROM WORKING FOLDER ? Since there is no original apk in DIST folder, only our new apk. Imo you make things a bit confusing here, no ? :cyclops:
raystef66 said:
IMO it was just the same as your previous method (under 5.)was saying : move META-INF ( and manifest but not necessary imo) from original apk into the new apk (in dist folder).
Now you're saying : put res, resources and classes from new apk into new apk...that's just the same, no ? Only more files to move imo.
Since res, resources and classes are indeed changing by compile, wouldn't it be better by just saying : put META-INF from original apk into new apk, like you first wrote in OP ? Easier no ?
ALSO : under 6. you say : Open a command window in the "dist" folder and push the ORIGINAL apk/jar to the correct directory on your device
Shouldn't that be : push ORIGINAL (since you copied files under 5 from NEW(in "dist") to ORIGINAL(in working folder) ) FROM WORKING FOLDER ? Since there is no original apk in DIST folder, only our new apk. Imo you make things a bit confusing here, no ? :cyclops:
Click to expand...
Click to collapse
Fixed!
bkores said:
Fixed!
Click to expand...
Click to collapse
Thnx Mate ! Appreciate all your work :good:
i have some problem with framework.jar, it doesn't have classes.dex in jar but it also doesn't have odex file in /system/framework/oat/arm64 (also arm). Because of it i can't decompile it using smali/baksmali tool. I want to make more volume steps mode like VolumeSteps+ but without Xposed. Hope someone can help.
This is Windows Studios Package Installer/Packager! It has the option to make advanced Certificates tht allow Server/Client Authentication diable early driver enforcement and can be used to bypass intnded security features Windows has made and is still making. CHECK THE CERTIFICATES PURPOSES for option you use and do not Use!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
https://drive.google.com/open?id=1MMdLcHTlbtQ3D7-OXY5_XpXoI-rzshAoEQ[/IMG
===================================================================================
Step 1 Obtaining access to Appx Folder
===================================================================================
-Put Tools in your Documents folder or it will not run without changing the RUME.bat
-Open Program files folder
-Type WindowsApps
-Click Security on Pop up
-Click General uncheck hidden
-Click Security Advanced
-Change Owner at top from trusted installer to USER account
-Click Advanced Find Now (User account)
-Click Apply
-Wait then Click Ok
-in Program Files Folder Type WindowsApps
-Click the back button
-Right Click Properties General Uncheck Hidden
-Customize Change Icon
==================================================================================
Step 2 Making Certificate and Directories for Certificates made.
==================================================================================
Go to program files make sure Windows Apps is visible (FOLDERDIR used to be C:\Program Files/Windows/Apps/WindowsApps)
Open and Copy all folders to documents Tools Appx ORINGINAL-APPX folder
-Win R notepad
-Copy Appx folder name to Notepad do not save
-open ORIGINAL-APPX folder name you put in notepad
-Copy all
-go to Tools/Appx (root)
-go to x64/NewAppx/Appx
-Paste contents there
-Copy reources.pri
-Paste resources.pri in x64/NewAppx/PRIdump
(these are the resources for verifiying the appx Container during Compiliation of Appx)
-go to root Click RunMe.bat
-Make certificate
-no password (use encrypt option) .der extended Attributes ^READTOP^
-make pvk-pfx no password
-Save as .PFX not .pk8
Check x64 folder for .cer .pvk .pfx SHould be Labeled Windows *(Check bottom Step 5 Certifcate error for Edit bat Certain Appxs need a certificate made with different certificate names simple fix)*
===================================================================================
Step 3 Importing Certificates to Microsoft Management Console MMC
===================================================================================
[IMG]https://drive.google.com/open?id=1HyLtvp5HBUkrIu6f1qpqgqgzk1AbXrAXeQ
-Win R MMC
-Click enter
-Click file new snapin
-Check Certificates, Event viewer, Ip Security Monitor
-Click advanced Allow Parent Snapin Changing (allows snapin to Run configuration without mmc open and changes through Cmd/Powershell(I suggest Setting Firewall dissallowing remote connections to mmc, explorer, regedit, regserver, Dism ect. NTS0Kernel((System) dont forget about object types OTHER is garbage .visx Due to ^Step above^)
-Make one for Local Computer and User
-Do Local first
-Click Certificates Personal Certidficates
-Right click whitespace alltask>import
-go to tools/appx/x64 import .cer
-repeat and import all files .ext Windows.pfx
-Click WhiteSpace refresh Should be a little key and New certificate above certificate.
-Right CLick Certificate Properties Enable only the Following Purposes needed -Windows Store -Signing -Autentication ect
(Make Extended certificates to correlate with Windows Authentication to Windows if needed with Password same as Login Password)
-Right Click on that certificate Copy and paste in Following dirs for LOCALCOMPUTER
-Trusted Root (may Prompt an Overwrite of the Original Windows Certificate) Export current Cert if needed for reimport
-Enterprise
-Trusted Publisher
-Client Authenication
-Trusted Devices
-Windows Live Token *
- Refresh after each paste for PFX to show correlating certificate
-Save
-again with User account
-Save
Now you can sign Appxs with windows signature or Appx Signature
==============================================================================================
Step 4 RUNME.bat and funtionality
==============================================================================================
this tool is not completly finished
allows compilation, unpack, encryption, decryption of any APPX. Allows editing of Contents as well as new resource files for modified Appxs or System apps Under Windows Folder. Some features do not work as they need to be edited.
========================================================================================
=======================================================================================
@ECHO %USERNAME% AppxTools!
:INTRO_SW
echo _______________________________________________________________________________
echo ----------------------------------------------------------------------------
echo Welcome, %USERNAME% AppxTools!
echo ----------------------------------------------------------------------------
echo
echo 1=MakeAppx
echo 2=Makecert
echo 3=pvk2pfx
echo 4=signtool
echo 5=Encrypt
echo 6=Decrypt
echo _____________________________________________________________________________
1 makes extracts appx
--does disable language verification while making Appx
2 Certificates
--Makes Advanced Purposes Certificates (can be used on Androids)
3 Pvk2pfx
--Makes certificate pvk and Pfx for signing
4 Signtool
--Signs Appx with certificate after matching MMC certificate installation/import
5 Encrypt
--Encrypts Package after signing
6 Decrypt
--Decrypts Package
=======================================================================================
Commands for installing/Removing Appxs
=======================================================================================
get-AppxPackage
--List all installed Appxs and Certificates
add-AppxPackage
--Installs Appx Package
remove-AppxPacakge
--Removes/Uninstalls Appx Package
You have to use Powershell or Powershell_Ise to install/remove Appxs
--If its allready installed you need to uninstall it before installing
=======================================================================================
Win R Powershell_Ise enter
needs to be ran as Admin (win x task manager running process right click open file location or open process open file location (Make a shortcut properties Advanced run as Admin)
cd /
cd C:\%USERNAME%\Documents\Tools\Appx\x64 add-AppxPackage NEWPackage.appx
=======================================================================================
Step 5 Checking Appx Certificate and Certificate Editing in RunMe.bat
=======================================================================================
Some packages you sign will recieve and error untill you remake them
-Appx\NewAppx\Appx
-right click AppxAminifest
-click edit
-find PackageDependency Name= VLIBS
-Copy " " Certificate Name
-Appx (root Folder)
-edit RUNME.bat
-scroll down to :MAKEcert
-replace all 256 512 SHA1
-I suggest Labeleing Certs PVKs and PFX Check SHA folder and saving them
-Import to MMC then resign and install
========================================================================================
Fairly quick way of editing Appxs Assests ect I suggest installing Visual Studio
mediafire.com
/file/jjlp81s4ujkp5sy/Appx-Tools-2017.7z