4 Replies Latest reply on Jun 15, 2014 10:14 AM by Jon Tara

    Sample Native Extension with Rho 4.1

    Hector Meza

      Has anyone gotten the native extension to work with Rho 4.1 based on the documentation example?


      Rhomobile | Building a native extension

      I was following the example but the extension is not being executed.  Set the trace and the log file does not show anything.


      The attached is using the basic greeting extension from the sample - main index has a call to a form which calls a method that should call the extension but - nothing.


      Sure I missed something minor but I am not seeing it.

      Ruby method is basic


        # call the greeting native extension

         def test1

            Alert.show_popup('before greeting')


          # call native extension

          msgval = Rho::Greeting.welcome("John Doe") # <= "Welcome, John Doe"

           Alert.show_popup('Extension: ['+msgval+']')  




      - attached is the sample project

        • Re: Sample Native Extension with Rho 4.1
          Kutir Mobility

          Hi Hector,

          I tried your sample project locally. It is throwing "Error: uninitialized constant Rho::Greeting" error in the log.

          I tried to call the extension method via Rho JavaScript. It is also throwing "Static method not found." error in the console

          I tried to fix it locally. But no luck :(. It's look like RhoMobile bug.


          Visnupriya R

          Kutir Mobility

            • Re: Sample Native Extension with Rho 4.1

              When building in RhoSimulator, it shouldn't build any of the native extensions which could explain why it's not recognized.  When I attempted to build for device, I received the following error.


              PWD: /Users/dhummel/Support/3069877/extensiontutorial/extensions/greeting/ext/platform/android

              rake arch:arm

              cd /Users/dhummel/Support/3069877/extensiontutorial/extensions/greeting/ext/platform/android

              cd ../../..

              rake aborted!

              Don't know how to build task '/Users/dhummel/Support/3069877/extensiontutorial/bin/tmp/greeting/arm/Greeting.cpp.o'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `eval'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `<main>'

              Tasks: TOP => arch:arm => /Users/dhummel/Support/3069877/extensiontutorial/bin/target/android/release/extensions/greeting/armeabi/libgreeting.a

              (See full trace by running task with --trace)

              rake aborted!

              Extension build failed: /Users/dhummel/Support/3069877/extensiontutorial/extensions/greeting/ext/platform/android

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.1.1/platform/android/build/android.rake:862:in `block (5 levels) in <top (required)>'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.1.1/platform/android/build/android.rake:848:in `each'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.1.1/platform/android/build/android.rake:848:in `block (4 levels) in <top (required)>'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.1.1/platform/android/build/android.rake:818:in `each'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.1.1/platform/android/build/android.rake:818:in `block (3 levels) in <top (required)>'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `eval'

              /Users/dhummel/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in `<main>'

              Tasks: TOP => device:android:debug => package:android => build:android:all => build:android:rhobundle => build:android:extensions

              (See full trace by running task with --trace)

                • Re: Sample Native Extension with Rho 4.1
                  Hector Meza

                  Looks like the 4.1 native extension build is leaving some stuff in that is should not.  You should delete the default Rakefile that is created for your extension


                  I found the following from the post on moving a 4.0 extension to 4.1,


                  # deleted:    extensions/externalstorage/ext/platform/android/Rakefile

                  This file gets created even if you initially build the extension with 4.1


              • Re: Sample Native Extension with Rho 4.1
                Jon Tara

                I didn't not have to change anything in my (iOS) native extension to move from 2.x to 4.1. The old extensions are supported as-is.


                I think you only need to generate a new extension if you want to use some new 4.x extension capability. The most obvious thing is creating a Javascript API. (I don't know if there are other 4.x-only features.) I don't need a Javascript API, so I did nothing.