filmil / sl4a-scheme

Automatically exported from code.google.com/p/sl4a-scheme
0 stars 0 forks source link

Add Android Proxy RPC Client class into dalvik jar to access SL4A API #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi !
I made a way to access SL4A API simply.
This issue might make great progress !!!
I was trying to add a new interpreter that does not exists yet.
And I noticed if the language could access to the classes(jar) it is able to 
use the SL4A API.
The technique could be applied with sl4a-scheme too.

Here is the way to progress sl4a-scheme !!!

1.Copy the "jscheme-7.2.jar" including classes.dex inside to a working folder.

2.Copy the "android.jar" in SDK(Android 1.5) to use "org.json.*" classes.

3.Build the "Android.java" for the rpc client class("Android.class"). The 
command will be like...
>javac -cp android.jar Android.java

4.Create this folder in your working folder.
"tmp\com\googlecode\rpc"

5.Copy the "Android.class" to "tmp\com\googlecode\rpc\"

6.Add the class to jar with this command.
>jar uvf jscheme-7.2.jar -C tmp\ com

7.Convert the JVM class to Dalvik(dex) class with this command.
>dx.bat --dex --verbose --statistics --keep-classes --core-library 
--output=FULLPATH_HERE\new-name.jar FULLPATH_HERE\jscheme-7.2.jar

;dx.bat has to be the Android 1.5 SDK
;Be careful the FULLPATH is required.

8.Rename "new-name.jar" to "jscheme-7.2.jar" and overwrite it.

9.Copy the new "jscheme-7.2.jar" to your android device 
"/sdcard/com.hdlfactory.scheme/extras/scheme/" and overwrite it.

10.Make this code and save it with the ".scm" extension.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import "com.googlecode.rpc.*")
(define droid (com.googlecode.rpc.Android.))
(.call droid "vibrate")
(.call droid "makeToast" "Hello Android!")
(exit)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

11.Try it !!!

Original issue reported on code.google.com by tomcatalbino on 27 Feb 2012 at 4:56

Attachments:

GoogleCodeExporter commented 9 years ago
This is the dalvik jar.

Original comment by tomcatalbino on 28 Feb 2012 at 11:40

Attachments:

GoogleCodeExporter commented 9 years ago
Hi. I'm Robbie, the current SL4A maintainer.
This does look hopeful, although traditionally we use script based bridging as 
being easier to maintain.
Does jscheme support sockets at all? If so, it should be easy enough to 
implement.

It would be better to include this as a source build of jscheme.jar rather than 
squeezing it into the prebuilt jar, but that is up to the project maintainers.

I do recommend leaving copious notes on your procedures... trust me, when you 
come back in a year or two to port a newer version of your interpreter, you do 
not want to be going "WTF did I do to make this work?"

If you can get the bridge working smoothly and get some user testing, I'd be 
happy to include this as a supported interpreter in Sl4A_R6 (R5 came out this 
afternoon, BTW, and has been tested with the current version of Schema)

Original comment by rjmatthews62 on 30 Mar 2012 at 2:04