CalebFenton/simplify

Loading android.jar classes in smalivm

guizos opened this issue · 3 comments

Hi,

Is there a way to load the Android standard libraries into the smalivm machine (i.e. android.jar)?

I'm trying to run an example but it requires a class android.os.ParcelUuid. I've implemented some of the methods separately but the problem I'm facing now is that I need to return a ParcelUuid object but when I do I get this exception:

Exception in thread "main" java.lang.RuntimeException: Real exception was thrown executing ExecutionNode{signature=Lbluetooth/le/external/d;->d(Landroid/os/ParcelUuid;)Z, op=invoke-virtual {r1, r0}, Landroid/os/ParcelUuid;->equals(Ljava/lang/Object;)Z, @=2} and was not handled. This could be a bug in smalivm.
Exception: java.lang.RuntimeException: Can't find Smali file for Landroid/os/ParcelUuid
	at org.cf.smalivm.NodeExecutor.execute(NodeExecutor.java:88)
	at org.cf.smalivm.MethodExecutor.execute(MethodExecutor.java:62)
	at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:103)
	at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:82)
	at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:68)
	at uk.ac.rhul.isg.ble.MainFitbit.executeFitbit_bluetooth_le_external_d_d(MainFitbit.java:44)
	at uk.ac.rhul.isg.ble.MainFitbit.main(MainFitbit.java:31)

So far, I've extracted the class from the android.jar, compiling it to smali and adding it to the dex file I have but this solution won't scale if I need other classes with dependencies.

Thanks!

Hello,

Yes, there is a way and for some reason it's not working for you. Did you clone the repo recursively? One way to check is to see if this file exists: smalivm/src/main/resources/framework/smali/android-25/android/os/ParcelUuid.smali. A Java class file should also exist in the JAR at smalivm/src/main/resources/framework/android-framework.jar, which is built from the framework smali files.

If you cloned recursively and those files exist already, then I'll need the information in the bug report template to reproduce. Most importantly, the sample or sample hash and the exact command you're executing.

Thanks a lot for your quick response. I just found that I was missing a semicolon in one of the assignParameter calls. It now works. Anyway, the information about the location of the jar is quite useful. Thanks a lot again!

Glad you fixed it. There's also smalivm/libs/android-local.jar which gets compiled into smalivm. So any classes therein which are also marked as safe in smalivm/src/main/resources/safe_classes.cfg will be reflected at runtime. Currently, this is only used for Android's Base64, but there's no reason you couldn't add other classes.