Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Manouchehri/68d270cd1129db8cf8a774f7eebe1979 to your computer and use it in GitHub Desktop.
Save Manouchehri/68d270cd1129db8cf8a774f7eebe1979 to your computer and use it in GitHub Desktop.
Wrapping java code to dalvik code, and executing it using Dalvik x86
/*
* author Huber Flores
*/
#Wrapping a java class into dex.
#Remember to add "dex" command to .bashrc file so that you can call the command from any place
#dex is an utility that comes with the Android SKD, and it's located in .../android-linux-x86_64/sdk/platform-tools/
#export PATH=$PATH:/home/ubuntu/android-sdk-linux/platform-tools:/home/ubuntu/CyanogenModBuild/environment/bin
$ nano Foo.java
public class Foo{
public static void main (String[] args){
System.out.println(System.currentTimeMillis() + "");
System.out.println("Here we do smt");
System.out.println(System.currentTimeMillis() + "");
}
}
$ javac Foo.java
$ dx --dex --output=foo.jar Foo.class
$ ./rund.sh -cp foo.jar Foo
#Run APK file
$ ./rund.sh HelloWorld.apk com.example.helloworld.Prueba
However, execution looks for main static to start
package com.example.helloworld;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
public class Prueba {
public static void main(String[] args) {
System.out.println("Esto es una prueba de ejecucion");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment