Decompile android.policy.odex - Galaxy Note GT-N7000 Android Development

Hello,
has someone successfully decompiled the android.policy.odex? I tried to include the extended Power Menu into the KJ4 Firmware, but deodexed decompiling did not work.
Any hints?
Code:
./baksmali android.policy.odex -x
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Ljunit/framework/TestCase;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:788)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:676)
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:104)
at org.jf.baksmali.main.main(main.java:282)
Error while loading class Landroid/test/AndroidTestCase; from file ./framework.zip
Error while loading ClassPath class Landroid/test/AndroidTestCase;

I'm getting a similar thing, trying to add items to the power menu, just can't seem to do it. Have you got any closer?
Sent from my GT-N7000 using Tapatalk

Meanwhile I have deodexed ROMs, KJ4 and KJA. Decompiling the android.policy.jar is no issue if the ROM is deodexed. Tonight I will upload the KJ8 ROM (KJ4 is already available here in the Forum).
Unfortunately the extended Power Menu doesn't work so far. I have tried to adapt SGS2 Howtos. But I was not successfull. There are some differences between SGS2 and Note, which I was not able to recover. I'm getting an "Array Index out of Bounds" Exception in the logcat as soon as I'm trying to call the Power Menu.

try java -jar baksmali.jar -c :core-junit.odex -d C:\framework -x android.policy.odex
put the core-junit.odex into the same folder with baksmali

Related

AndroidManifest.xml (and maybe other) problems

Hi all,
I modifed an app so that it would run on my phone--I have a cyanogen ROM, and it doesn't play well. The app runs fine on my wife's stock G1. Anyway, I used baksmali and smali to make the necessary changes, and it recompiles fine. I also "decrypted" the AndroidManifest.xml (from binary to text), resigned the package, and I get the dreaded "file does not contain AndroidManifest.xml" error.
Apparently, the AndroidManifest.xml doesn't get built back to its binary mode during the package signing.
1. How do I get AndroidManifest.xml back into its proper binary format?
2. Is there anything else I am missing?
Thanks.
The XML files are converted during the process of building the .apk file, i.e. by "aapt". You can do this manually if you want.
http://developer.android.com/guide/developing/tools/aapt.html
derfolo said:
I also "decrypted" the AndroidManifest.xml (from binary to text)
Click to expand...
Click to collapse
By what means did you accomplish this? Did you use aapt or did you do it manually?
lbcoder,
There is a handy tool to do this called AXMLPrinter2.jar. It is available here:
http://code.google.com/p/android4me/downloads/detail?name=AXMLPrinter2.jar&can=2&q=
I am having problems using aapt to "binarize" only the AndroidManifest.xml file. I can't package the entire app, because the baksmali files are not recognizable by Eclipse as java files, and when I use smali, it is all converted back into classes.dex. Any ideas?
Just to be clear, I am doing:
Code:
./aapt package -z -u -A ./app.directory -F ./app.name.apk
An .apk file pops up with no errors, but: 1) AndroidManifest.xml is not converted to binary, and 2) the same error "does not contain AndroidManifest.xml" occurs.
Thanks for any help.

how do you open and edit classes.dex?

I can not open classes.dex for the life of me. I have tried multiple ways with different commands and such and still can not get it to open.
I have found this method to get me the farthest but still no go on opening it. every time I enter the command
java -jar baksmali.jar -o classout/ classes.dex
Click to expand...
Click to collapse
I get "Unable to access jarfile baksmaili.jar"
Thanks to anyone who is willing to help.
Download AvaboxV2 and unzip the folder. Inside there are tools for editing and such, namely the "Smali" folder which is hopefully what you are looking for.
kyouko said:
Download AvaboxV2 and unzip the folder. Inside there are tools for editing and such, namely the "Smali" folder which is hopefully what you are looking for.
Click to expand...
Click to collapse
I tried that. It will only do apks... I need to to do it to a .dex or a .jar
okay now I see the folder C:\Users\Devin\Documents\AvaboxV2\Smali\baksmali
but still I will need the command prompt and I will be in the same trouble i am in now.
Put the classes.dex file in the \smali\baksmali folder. then navigate to that folder in command prompt:
Code:
cd\
cd C:\Users\Devin\Documents\AvaboxV2\Smali\baksmali
java -jar baksmali-1.1.jar -o classout/ classes.dex
*that should create a folder called "classout" in \baksmali with the smali files*
Then make your edits to the .smali files using notepad++ or w/e
To close up the classout folder and put it back into a classes.dex enter this in cmd:
Code:
java -jar smali-1.1.jar classout -o classes.dex
Edit: fixed file name mix-up
kyouko said:
Put the classes.dex file in the \smali\baksmali folder. then navigate to that folder in command prompt:
Then make your edits to the .smali files using notepad++ or w/e
To close up the classout folder and put it back into a classes.dex enter this in cmd:
Code:
java -jar smali-1.2.1.jar classout -o classes.dex
Click to expand...
Click to collapse
dude no matter what I type cmd will NOT go to that folder. "Folder not found" or some ****.
I can NOT wait till iPhone 4 comes out android is total ****.
got it to go to teh folder in cmd but like I said i get the stupid ass unable to access jarfile baksmali.jar
When baksmali.jar is clearly in the freaking folder.
Is there not an easier way to do this?
Ooohhh shii- lol I'm a dumbass
Haha it should be baksmali-1.1.jar and smali-1.1.jar
I just edited my previous post to fix that mixup
I even pasted strait from yours.. it does not work man. I give up android is gay
Never mind thank you so much man.. I was just getting pissed off because I have been trying this for so long. Thanks for the help.
Funny thing is, you think you'll be able to mod I phone easier? Ha!
-------------------------------------
Sent via the XDA Tapatalk App
roflcopter
danaff37 said:
Funny thing is, you think you'll be able to mod I phone easier? Ha!
-------------------------------------
Sent via the XDA Tapatalk App
Click to expand...
Click to collapse
..Thumbs up
Srsly..its not difficult to mod android and its apps/framework(/resources)...at all. Only 2 real vars: setup and level of incompetence
not related->Getting a mac soon, mostly everything is windows compatible (80% of market/business/etc), mac not so much...parallel+windows 7 good idea?
kthxbai
I run a dual boot between ubuntu and windows 7 for work
Sent from my HERO200 using XDA App
Anyone have a clue why i get this error?
Smali\baksmali>java -jar framework.jar
-o classout/ classes.dex
Failed to load Main-Class manifest attribute from
framework.jar
This prog hero specific?
Thanks'
hellmonger said:
Anyone have a clue why i get this error?
Smali\baksmali>java -jar framework.jar
-o classout/ classes.dex
Failed to load Main-Class manifest attribute from
framework.jar
This prog hero specific?
Click to expand...
Click to collapse
it not hero specific > link
framework.jar doesn't have the "Main-class" header which is why you're getting that error.
it should be
Code:
java -jar baksmali.jar -o classout/ classes.dex
NOT
Code:
java -jar [COLOR="red"]framwork[/COLOR].jar -o classout/ classes.dex
java -jar is used to run the baksmali and smali.jar "applications"
can this be done in window? cygwin? I have tried to call baksmali for a classes.dex also and having no luck. any insight?
thank
thanksssssss
this app, everytime i start it, i have to press OK button (that annoying) but it work. see what can we do with it:
- i try to extract the classes.dex file, (using winrar)
- edit some code (to remove the dialog appear when it start),
- compress the code back .dex file
- put the .dex into .apk file
- install on the phone fail
can anyone give me suggestion or please do something..
khanhj said:
this app, everytime i start it, i have to press OK button (that annoying) but it work. see what can we do with it:
- i try to extract the classes.dex file, (using winrar)
- edit some code (to remove the dialog appear when it start),
- compress the code back .dex file
- put the .dex into .apk file
- install on the phone fail
can anyone give me suggestion or please do something..
Click to expand...
Click to collapse
Why you have attached a warez spy app?
Can anyone tell why I get this error?
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: bad magic value: 64 65 79 0a 30 33 36 00
at org.jf.dexlib.DexFile.<init>(DexFile.java:359)
at org.jf.baksmali.main.main(main.java:176)
Using Win7. I've always just thrown all editing files in Android/SMALI folder.
Hold Shift, Right Click "Open Command Window Here".
Then for compressing/decompressing the commands I use are.
java -jar baksmali.jar -o classout/ classes.dex
java -Xmx512M -jar smali.jar classout -o classes.dex
Haven't run into any issues yet. I noticed no one has put the "-Xmx512M" in their code.
I hope this helps.

[Guide] How to deodex SMemo.apk

SMemo.apk is making problem when trying to deodex it.
I found the dependencies files and it works great!
Download the 2 attached files: servlet.jar and memo.jar
put these files in your framework folder
Use these files to deodex SMemo.apk -
twframework.jar
com.google.android.maps.jar
secmediarecorder.jar
memo.jar
servlet.jar
deodex your SMemo.apk
Good luck! Don't forget to hit the "Thanks" button :good:
Nice work dude!
You also need twframework.jar and com.google.android.maps.jar but those are to find in /framework.
But anyway there are still some errors:
Code:
Error while disassembling method Lcom/diotek/gdocs/util/GDocsSync$1;->run()V. Continuing.
org.jf.dexlib.Code.Analysis.ValidationException: Could not resolve the field in class Lcom/diotek/gdocs/util/GDocsSync; at offset 120
added full list of jar needed to deodex SMemo
firefds said:
added full list of jar needed to deodex SMemo
Click to expand...
Click to collapse
hm still the same
Code:
Error while disassembling method Lcom/diotek/gdocs/util/GDocsSync$1;->run()V. Continuing.
org.jf.dexlib.Code.Analysis.ValidationException: Could not resolve the field in class Lcom/diotek/gdocs/util/GDocsSync; at offset 120
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeInstruction(MethodAnalyzer.java:1084)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyze(MethodAnalyzer.java:213)
at org.jf.baksmali.Adaptors.MethodDefinition.addAnalyzedInstructionMethodItems(MethodDefinition.java:379)
at org.jf.baksmali.Adaptors.MethodDefinition.writeTo(MethodDefinition.java:132)
at org.jf.baksmali.Adaptors.ClassDefinition.writeMethods(ClassDefinition.java:338)
at org.jf.baksmali.Adaptors.ClassDefinition.writeTo(ClassDefinition.java:117)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:205)
at org.jf.baksmali.main.main(main.java:297)
opcode: iput-quick
CodeAddress: 3
Method: Lcom/diotek/gdocs/util/GDocsSync$1;->run()V
What version of smali/baksmali are u using?
Bak/smali 1.3.2
Dont forget to add the -a 15 tag
Sent from my GT-I9300 using xda premium
Hi~
Thanks for your method, I can deodex SMemo.apk, now.
Do you know how to deodex SlideShow.apk?
I got this error message as below
Code:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Lcom/sec/android/gallery3d/app/AbstractGalleryActivity;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:830)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:683)
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:104)
at org.jf.baksmali.main.main(main.java:293)
Error while loading class Lcom/sec/android/gallery3d/util/KeyBoardManager; from file ./system/app/SlideShow.odex
Error while loading ClassPath class Lcom/sec/android/gallery3d/util/KeyBoardManager;
Yes.. take the secGallery2.apk from the app folder and change it to .jar
Then stick it in the framework folder snd use it to deodex slideShow.apk
Dont forget to delete it before flashing!
Sent from my GT-I9300 using xda premium
mike1986. said:
hm still the same
Code:
Error while disassembling method Lcom/diotek/gdocs/util/GDocsSync$1;->run()V. Continuing.
org.jf.dexlib.Code.Analysis.ValidationException: Could not resolve the field in class Lcom/diotek/gdocs/util/GDocsSync; at offset 120
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyzeInstruction(MethodAnalyzer.java:1084)
at org.jf.dexlib.Code.Analysis.MethodAnalyzer.analyze(MethodAnalyzer.java:213)
at org.jf.baksmali.Adaptors.MethodDefinition.addAnalyzedInstructionMethodItems(MethodDefinition.java:379)
at org.jf.baksmali.Adaptors.MethodDefinition.writeTo(MethodDefinition.java:132)
at org.jf.baksmali.Adaptors.ClassDefinition.writeMethods(ClassDefinition.java:338)
at org.jf.baksmali.Adaptors.ClassDefinition.writeTo(ClassDefinition.java:117)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:205)
at org.jf.baksmali.main.main(main.java:297)
opcode: iput-quick
CodeAddress: 3
Method: Lcom/diotek/gdocs/util/GDocsSync$1;->run()V
What version of smali/baksmali are u using?
Click to expand...
Click to collapse
It's working here with the kitchen 1.9.6, thanks firefds.
firefds said:
Bak/smali 1.3.2
Dont forget to add the -a 15 tag
Sent from my GT-I9300 using xda premium
Click to expand...
Click to collapse
1.3.3 >^^<
http://forum.xda-developers.com/showpost.php?p=26007283&postcount=1
I have a problem... how to solve?
Code:
All ODEX files:
(1) ./system/app/SlideShow.odex
(2) ./system/app/SMemo.odex
Enter file number (0 = cancel): 2
Enter any JAR file dependencies separated by colon (Enter=none).
NOTE: To ignore errors, type 'ignore' by itself or after dependencies
./system/app/SMemo.odex > smemo.jar servlet.jar
Disassembling ./system/app/SMemo.odex ...
java -Xmx512m -jar baksmali.jar -a 15 -d system/framework -x ./system/app/SMemo.odex
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Lcom/sec/android/framework/draw/Stage;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:830)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:683)
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:104)
at org.jf.baksmali.main.main(main.java:293)
Error while loading class Lcom/diotek/diodraw/Stage; from file ./system/app/SMemo.odex
Error while loading ClassPath class Lcom/diotek/diodraw/Stage;
Try ./system/app/SMemo.odex again (y/n)? (default: y):
roxdragon said:
I have a problem... how to solve?
Code:
All ODEX files:
(1) ./system/app/SlideShow.odex
(2) ./system/app/SMemo.odex
Enter file number (0 = cancel): 2
Enter any JAR file dependencies separated by colon (Enter=none).
NOTE: To ignore errors, type 'ignore' by itself or after dependencies
./system/app/SMemo.odex > smemo.jar servlet.jar
Disassembling ./system/app/SMemo.odex ...
java -Xmx512m -jar baksmali.jar -a 15 -d system/framework -x ./system/app/SMemo.odex
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Lcom/sec/android/framework/draw/Stage;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:830)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:683)
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:104)
at org.jf.baksmali.main.main(main.java:293)
Error while loading class Lcom/diotek/diodraw/Stage; from file ./system/app/SMemo.odex
Error while loading ClassPath class Lcom/diotek/diodraw/Stage;
Try ./system/app/SMemo.odex again (y/n)? (default: y):
Click to expand...
Click to collapse
Put your 2 jar files on /framework and try with option "a" (deodex app folder).
Solved thank youuuuu!
I must remove files / dependences?
firefds said:
Dont forget to delete it before flashing!
Sent from my GT-I9300 using xda premium
Click to expand...
Click to collapse
1. Into /system/app i have SecGallery2.jar ...rename it SecGallery2.apk?
2. I need delete "servlet" and "SecGallery2.jar" into /system/framework before flashing?
Thank you!
Anyone have a working deodexed SMemo they can put up a download for? I removed my originals from the phone and the odexed ones aren't working as it just FCs every time. All other apps are working great when I restore in system/apps
ok,solve problems,thanks
all framework add,it‘s do it,thanks!
I would also like a download link if possible? this is all to much for me to do myself, im ok rooting, modding framework & system apps but i cant get my head round things like this? If anyone gets this working please send me a Private Message with the link please? Would really like this too
I pulled SMemo app & SMemo Provider apks from the DragonICS Rebirth rom & added it to my rom & I now have SMemo, also pulled Voice Recorder too :0)
Sent via my pimped out Samsung Galaxy S III using Tapatalk
I am tired and I need help...what am I doing wrong>??
the command where I need to deodex the .odex file, it NEVER makes the damn 'out' folder...
it spits out some weird help menu..
-a, --api level
-b,-- no-debug-info
this sort of ****...plz someone help me..
this is neither an error, nor is it a solution...i dont know what to Google also?
This would be amazing if it got done. Keep up the great work guys
This method is not needrd anymore.. just use baksmali/smali 1.3.3. No need for extra files
Sent from my GT-I9300 using xda premium

[HELP] 'Java' is not recognized...

Hi everyone, I was trying to edit an apk file (it's the first time I try) and when I try to decompile classes.dex with dex2jar the console says "java is not recognized as an internal or external command"... I tried to set new PATH and CLASSPATH with the value as the address where's located java.exe and it still doesn't work..
Anyone can help me?
EDIT: New issue when I try do decompile a classes.dex file: "Error: Could not find or load main class com.googlecode.dex2jar.v3.Main"... I'm being mad with these errors...
Anyone can help me with this?
smoza said:
Hi everyone, I was trying to edit an apk file (it's the first time I try) and when I try to decompile classes.dex with dex2jar the console says "java is not recognized as an internal or external command"... I tried to set new PATH and CLASSPATH with the value as the address where's located java.exe and it still doesn't work..
Anyone can help me?
EDIT: New issue when I try do decompile a classes.dex file: "Error: Could not find or load main class com.googlecode.dex2jar.v3.Main"... I'm being mad with these errors...
Anyone can help me with this?
Click to expand...
Click to collapse
This is likely obvious, but do you have Java installed?
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Fixed: I set the enviroment paths in the wrong way :laugh:

Theming mediatek-res.apk

I have been interested in theming an MTK 6592 mediatek phone (Infinix Hot Note x551) I have owned for quite a while. Its currently running Stock Android 5.1 Lollipop.
I reached a point where I needed to decompile and recompile the mediatek-res.apk framework resource app.
I was using apktool version 2.1.1 and later on 2.2.0-a4270d-SNAPSHOT
I wanted to get rid of this notification item, every time you opened the Dialer, Contacts or Mms application. I found it annoying - asking every time to choose a default simcard, when I clearly wanted and is able to choose a line on calls, or outgoing SMSs.
Sorry, cant post image links yet!!
Click to expand...
Click to collapse
After a few weeks of on-of/trial and error research, I realized that these could be accomplished by editing the mediatek-res.apk located in /system/framework/mediatek-res.
It decompiled ok, but could not compile after editing(again, trial-error).
These were the compilation errors I was getting: A tonne of errors concerning all the resources and their Id's:
HTML:
W: /home/*****/Desktop/mtk/mediatek-res/res/layout/account_five.xml:6: error: Error: No resource found that matches the given name (at 'id' with value '@id/account_five_img').
I read up on this error and one post here on XDA (didnt save the link, sorry) and also over at github, said to edit the apktool.yml file and include the framework ID for the mediatek-res.apk (already installed via 'apktool if mediatek-res.apk'). Its framework ID was 8. So I added it.
HTML:
usesFramework:
ids:
- 1
to
HTML:
usesFramework:
ids:
- 1
- 8
On compilation, a ton of these new errors came up:
HTML:
W: /home/*****/Desktop/mtk/mediatek-res/res/values/styles.xml:3: error: Resource entry style/ImageSwitch is already defined in package com.mediatek.
Looked around furrther for quite sometime couldnt get a solution to this new errors. I continued on my trial and error ways and discovered that If edited the apktoo.yml file
HTML:
sharedLibrary: false
to
HTML:
sharedLibrary: true
and removed the mediatek-res framework ID from apktool.yml file, the errors were reduced to TWO!!
HTML:
W: /home/*****/Desktop/mtk/mediatek-res/res/values/public.xml:914: error: Public symbol ^attr-private/factor declared here is not defined.
HTML:
W: /home/*****/Desktop/mtk/mediatek-res/res/values/public.xml:915: error: Public symbol ^attr-private/scale declared here is not defined.
On investigating the error, I found out that indeed the two resources( ^attr-private/scale & ^attr-private/factor) were not defined in Ids.xml located in /res/values. I added the two to the bottom of the file,
HTML:
<item type="^attr-private" name="factor">false</item>
<item type="^attr-private" name="scale">false</item>
Also I renamed the file ^attr-privates.xml to ^attr-private.xml
On compilation, NO ERRORS!! and the app but pushed to system the phone ends up in endless bootloop.
I finally resolved the bootloop by replacing the resources.arsc in the compiled apk by the one from the original resources.arsc. They differ in size by a few kilobytes.
STEP BY STEP
1. Using APK Multi-Tools, use option
1. Extract APK
Click to expand...
Click to collapse
. Go to Projects folder and copy the resources.arsc file. This is the original file you shall place in the compiled app.
2. Compile as usual the modified mediatek-res app.
3. Go to '/Build/apk' folder and replace the resources.arsc therein with the one from setp 1.
4. Compile a second time.
5. Your apk will be able to boot and run ok now.
Because I am not very well versed with apktool and its inner workings, I don't know why this errors came up. I know this is a work-around, but for now it will have to do.
If this post saves you a few hours/days/weeks of research, hit thanks!!

Categories

Resources