Ruboto Platform APK #64

Closed
donv opened this Issue Aug 21, 2011 · 4 comments

Comments

Projects
None yet
1 participant
Owner

donv commented Aug 21, 2011

Many issues lead to this: Having a platform APK that contains and offers jruby-core and jruby-stdlib and possibly more to other APKs running on the same device.

If we make an APK with jruby-core and jruby-stdlib packed at the root of the APK, we could add the APK to the classpath at runtime.

First stab it this:

            String packagePath = "org.ruboto.core";
            String classPath = "org.jruby.embed.ScriptingContainer";

            String apkName = null;
            try {
                apkName = getPackageManager().getApplicationInfo(packagePath,0).sourceDir;
            } catch (PackageManager.NameNotFoundException e) {
                // catch this
            }

            // add path to apk that contains classes you wish to load
            String extraApkPath = apkName + ":/path/to/extraLib.apk"

            PathClassLoader pathClassLoader = new dalvik.system.PathClassLoader(apkName, ClassLoader.getSystemClassLoader());

            try {
                Class<?> handler = Class.forName(classPath, true, pathClassLoader);
            } catch (ClassNotFoundException e) {
                // catch this
            }

References

The code above works in that we can load a class from the other APK.

How do we make sure the classloader is used for the entire app?

Owner

donv commented Aug 22, 2011

I have made an org.ruboto.core platform app and a mini_app without jruby-core.jar and successfully loaded and started a ScriptingContainer in the mini_app using the JAR from the platform APK.

Things are looking good.

I am stuck at adding the platform APK to the load path. Currently I fail to load builtin/javasupport. Anybody got a tip? How do I enable loading scripts from the pathClassLoader?

Owner

donv commented Aug 22, 2011

I bloody did it!

Got a working Platform APK + App APK working!

Owner

donv commented Aug 23, 2011

I am thinking that we should make small apps the default with the option to embed the jruby jars in the application like we do now.

"ruboto gen app" should not add the jruby jars to the project.

"ruboto gen jruby" is used to add the jruby jars.

"ruboto update app" updates the jruby jars only if they are already present.

donv closed this Aug 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment