1 / 22

Ruboto – Ruby on Android

Ruboto – Ruby on Android. Introduction. Ruby on Android Rhodies Scripting layer for Android Rhuboto Goal of Ruboto Make Jruby a first class language on Android. Flow of Ruboto. Ruby and Java. Ruboto is a framework for writing full Android apps in Ruby.

royal
Download Presentation

Ruboto – Ruby on Android

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ruboto – Ruby on Android

  2. Introduction • Ruby on Android • Rhodies • Scripting layer for Android • Rhuboto • Goal of Ruboto • Make Jruby a first class language on Android

  3. Flow of Ruboto

  4. Ruby and Java • Ruboto is a framework for writing full Android apps in Ruby. • It includes support libraries and generators for creating projects, classes, tests, and more. • Ruboto expose the complete Android API • we use Java source in a Ruboto project • we add ruby source to a Java Android project

  5. Advantage of Ruboto And JIT • Ruboto project IS an Android Java project. You can choose which parts of the app you want to write in Ruby, and which parts you want to write in Java. • Developing in Ruby allows you a quick development cycle and more maintainable code • Developing in Java allows for higher performance. • Right now we have the dexmaker.jar based Dalvik byte code generation which is used for generating subclasses of Java classes.

  6. Include Jruby • Include the --with-jruby flag when you create your app with ruboto gen app • After generating an app you can type ruboto update jruby --force and the two jars will be included in your libs directory. You will have to have the jruby-jars gem installed in your Ruby installation. • If you would like to remove JRuby from your app, just delete libs/jruby-*.jar from your project.

  7. JIT and Size • Ruboto not support JIT compilation to Dalvik byte code • Right now we have the dexmaker.jar based Dalvik byte code generation which is used for generating subclasses of Java classes. • A "Hello World" type application (apk) is less than 40KB. The application installed on the device is less than 100KB • Ruboto Core platform app installed, which adds just above 9MB of installed disk space. • Adding the dx library for JIT compilation would add up to 747KB.

  8. RUBOTO-irb • This is a Developer tool for check the code on devise befor developing app • start demo-irb-server.rb file • adb forward tcp:8005 tcp:8005 • Localhost:8005 on browser

  9. Prerequisites

  10. Installations • java&Ant • http://www.oracle.com/technetwork/java/javase/downloads/index.html • Sudo apt-get install ant1.8 (for ubuntu) • http://ant.apache.org/bindownload.cgi • Ruby,Ruby gems and Rake • Use of jruby is optional • gem install ruboto • Gem install rake • Android sdk and plat forms • http://developer.android.com/sdk/index.html • add the sdk's tools/ and platform-tools/ directory to your $PATH • dx –version android -s create avd -f -n Android_4.1 -t android-16 --sdcard 64M emulator -avd Android_4.1 • Gems:ruboto-core & jruby-jars • gem install ruboto-core • gem install jruby-jars

  11. Generate app • ruboto gen app --package com.yourdomain.whatever --path path/to/where/you/want/the/app --name NameOfApp --target android-version --min-sdk another-android-version --activity MainActivityName • --path --> Path of app folders to generate • --name --> Name of app ( custom edit) • --target --> Target android version • --min-sdk --> minimum sdk supported fotr this app • --activity --> Main activity class name • --with-jruby --> includes jruby jars in lib/

  12. Simple button click app • ruboto gen app --package com.ruboto.buttonclick • You can see the default folders and files generated • edit the code on src/buttonclick_activity.rb with the code • Refer:- buttonclick.zip/src/buttonclick_activity.rb

  13. Use of Sqlite Databade app • ruboto gen app --package com.ruboto.sqlite • You can see the default folders and files generated Create a new file Gemfile.apk, and add the code Refer:- sqlite.zip/Gemfile.apk Configure load path Create a new file src/config.rb, and add the code Refer:- sqlite.zip/src/config.rb Then add this line just below the top of src/sqlite_ar_activity.rb: require 'config' Configure database Create a new file src/android_logger.rb Refer:- sqlite.zip/src/android_logger.rb

  14. Use of Sqlite Databade app Create a new file src/database.rb Refer:- sqlite.zip/src/database.rb Load the file at the end of src/config.rb with_large_stack{require 'database'} Create a new file src/migrate.rb MIGRATION_PATH = File.expand_path("#{SRC_DIR}/migrate") puts "Looking for migration scripts in #{MIGRATION_PATH}" migrator = ActiveRecord::Migrator.new(:up, MIGRATION_PATH) if migrator.pending_migrations.size > 0 puts "Found #{migrator.pending_migrations.size} migrations." migrator.migrate End Load the file at the end of src/config.rb with_large_stack{require 'migrate'}

  15. Use of Sqlite Databade app Create a new file in src/migrate/001_create_people.rb Refer:- sqlite.zip/src/migrate/001_create_people.rb Add data and display table Create a new file src/person.rb class Person < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name End

  16. Use of Sqlite Databade app Edit src/sqlite_ar_activity.rb to Refer:- sqlite.zip/src/sqlite_ar_activity.rb

  17. Spy cam App • ruboto gen app --package com.ruboto.spycam • You can see the default folders and files generated • Add a new file src/spycam_server.rb: Refer:- spycam.zip/src/spycam_server.rb Add permissions Add the following lines to you AndroidManifest.xml file, just after the uses_sdk tag: <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-feature android:name="android.hardware.camera"/> <uses-feature android:name="android.hardware.camera.autofocus"/> Refer:- spycam.zip/AndroidManifest.xml

  18. Spy cam App Activate the web server Edit src/spycam_activity.rb to this: Refer:- spycam.zip/src/spycam_activity.rb Take a picture Add a new file src/camera_helper.rb: Refer:- spycam.zip/src/camera_helper.rb Ater Deploy app with command from root directry Rake install The app should restart and show two lines of information: Server: WEBrick started on http://xxx.xxx.xxx.xxx:4567/ Picture: Point a web browser to the given URL. You should get a web page with a picture from the camera. Click the camera to update the picture.

  19. Issues • Issues • Startup sppd • Stack limits • Appsize • Compiling Ruby • Generating Byte code

  20. Limitations • Mobile hardware Limitations(Memory Stack limit) • Delvik VM (jar include) • Requesting control from java • Jruby exes components • Android resourrce framework(Losing Dynamic programing)

  21. Thank you

  22. Any Queries

More Related