AizazSharif / smali

Automatically exported from code.google.com/p/smali
0 stars 0 forks source link

Suggestion: Android version #214

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is just a suggestion, but I can't find anywhere better to make it.  Given 
that we're using this tool to make modifications of Android files, sometimes it 
could be very useful to be able to modify them directly from the device itself. 
 Sometimes we don't necessarily have access to a computer for one.  But also 
with Bluetooth keyboards and such it can be almost as easy to do such things 
from the device itself anyway.  Plus it's often really small changes anyway 
(for instance, I'm just using this to modify the pre-defined values for the 
number of volume control steps so I can get actual precise volume control.)

Original issue reported on code.google.com by nazo...@gmail.com on 26 May 2014 at 9:23

GoogleCodeExporter commented 9 years ago
Just use dx on the smali.jar or baksmali.jar, and you can run the resulting dex 
file on a device, using something like terminal emulator.

See 
http://stackoverflow.com/questions/10199863/how-to-execute-the-dex-file-in-andro
id-with-command for an example of how to run a command-line utility on the 
device

Original comment by jesusfreke@jesusfreke.com on 26 May 2014 at 11:15

GoogleCodeExporter commented 9 years ago
How would you modify, say, the framework.jar this way though?

Original comment by nazo...@gmail.com on 27 May 2014 at 1:26

GoogleCodeExporter commented 9 years ago
There would be no difference from the way you would do it from your desktop 
machine. Run baksmali, edit the generated files using <android text editor of 
choice>, reassemble with smali, and replace framework.jar, assuming you have 
root access of course.

Original comment by jesusfreke@jesusfreke.com on 28 May 2014 at 12:17

GoogleCodeExporter commented 9 years ago
Thanks.  I still hold to the recommendation that some sort of actual Android 
version would be really nice though.

Original comment by nazo...@gmail.com on 28 May 2014 at 2:55

GoogleCodeExporter commented 9 years ago
I tried that and it doesn't work.  Javac requires "annotation processing" and I 
have no clue what that means to manually do it.  My guess is its methodology 
has changed at some point in the two years since the post linked to above was 
written.

Original comment by nazo...@gmail.com on 1 Jun 2014 at 4:08

GoogleCodeExporter commented 9 years ago
Nope, it still works.

Original comment by jesusfreke@jesusfreke.com on 1 Jun 2014 at 4:27

GoogleCodeExporter commented 9 years ago
D:\Android\sdk\sdk\build-tools>"C:\Program Files\Java\jdk1.8.0_05\bin\javac.exe"
 Smali.jar
error: Class names, 'Smali.jar', are only accepted if annotation processing is e
xplicitly requested
1 error

From the help I see that you can specify -proc:only to tell it to do this 
annotation processing whatever that is, but this is the result then:
D:\Android\sdk\sdk\build-tools>"C:\Program Files\Java\jdk1.8.0_05\bin\javac.exe"
 -proc:only Smali.jar
warning: Annotation processing without compilation requested but no processors w
ere found.
error: Class names, 'Smali.jar', are only accepted if annotation processing is e
xplicitly requested
1 error
1 warning

I have no clue how to specify processors for it or for that matter if this is 
even the right way to do this.

Original comment by nazo...@gmail.com on 1 Jun 2014 at 4:32

GoogleCodeExporter commented 9 years ago
javac is the java compiler. It takes java source code and produces java class 
files. It has no idea what to do with a jar file. (hint: a jar file is just a 
collection of .class files.. you can skip the javac step)

Original comment by jesusfreke@jesusfreke.com on 1 Jun 2014 at 8:42

GoogleCodeExporter commented 9 years ago
I could have sworn I tried dx first and it gave me an error, but, well, it 
worked this time, so I guess not.  However, the dalvikvm command requires a 
classname -- what do I give it?  

Original comment by nazo...@gmail.com on 1 Jun 2014 at 2:50

GoogleCodeExporter commented 9 years ago
It should be org.jf.baksmali.main and org.jf.smali.main

Original comment by jesusfreke@jesusfreke.com on 1 Jun 2014 at 7:27