Tested on Android ICS.


- Making Android project that has normal java entry function - 'public static void main(String[] args) { ...  }'.

  (ex. make 'public static void main(String[] args) { ... }' at 'my.test.Main' )

my/test/Main.java

-----------------


    package my.test;

public static void main(String[] args) {

System.out.println("Hello!");

}

- Making 'xxx.apk' by exporting Android project. (You don't need to care about signing.)

- Let's test with following commands

    $> adb push xxx.apk /data

And then programs can be run with following commands

    $> export CLASSPATH=/data/xxx.apk
    $> app_process /system/bin my.test.Main
or
    $> export CLASSPATH=/data/xxx.apk
    $> dalvikvm my.test.Main
or
    $> dalvikvm -classpath /data/mytest.apk my.test.Main

'main' function should be run.


IMPORTANT POINT here is knowing that 'apk' is a kind of 'jar' in JAVA.

See inside 'apk', then you can figure out structure of 'apk' is very similar with 'jar'.

And this is the hint of above way.


And, you can also find classes.dex at <android project root>/bin/ . and this is just like classes.jar of java.

So, this classes.dex can be replace xxx.apk above.


WARNING!



+ Recent posts