RubyMotion Android is in motion

At InfiniteRed we’ve been building a real (for existing users) RubyMotion Android app, Darin Wilson has been doing all of it. It’s the Android version of an iOS app we’ve already built. I wanted to give you an update on Android and share some of our experiences.

First: Darin is going to do an RM Android tip in every Dispatch, to help everyone out.

Second: there are still issues with RM Android. Darin is submitting bug reports daily as he finds bugs or missing pieces. As you can see from RM v3.3 below they’re getting fixed.

We’ll keep you updated as Darin continues to travel the undiscovered country, hacking through the prickly foliage.

If you missed the last issue, you can find it here: issue #51.

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


new book | by Lori Olson
Core Data in Motion“, here is a blog post talking about it.

January 23th, 2015 | gem update | by Todd Werth
RMQ Version 1.1.0 released

January 21th, 2015 | gem update | by Jamon Holmgren
ProMotion Version 2.2.1 released

January 19th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – RubyMotion for Rails Developers: Table Views (part 4) – Interaction

January 16th, 2015 | blog post | by RubyMotion
RubyMotion Success Story: Freckle

January 15th, 2015 | new gem | by Mark Rickert
motion-imager – An interactive iOS image viewer that does it all: double tap to zoom, flick to dismiss, et cetera.

January 13th, 2015 | screencast | by Jack Watson-Hamblin
MotionInMotion – RubyMotion for Rails Developers: Table Views (part 3) – Custom Cells

RubyMotion News


RubyMotion 3.3 released

  • [iOS] Fixed a bug where a WatchKit application could be launched on an iOS
    8.1 simulator, which does not actually support WatchKit and would crash.
  • [iOS] Fixed a bug where the compiler would no longer emit proper DWARF
    metadata for ARM64 due to an Xcode / clang change.
  • [iOS] Print an informative error when no simulator devices are configured.
  • [iOS, OSX] Fixed a bug where the #== method in a pure Ruby object would
    not resolve WeakRef operands.
  • [iOS, OSX] Fixed a bug where small structure cannot be passed into
    Objective-C functions with 64-bit app.
  • [iOS, OSX] Fixed a bug where the #kind_of? method in an ImmediateRef would
    not compare against the reference object’s class.
  • [iOS, OSX] Fixed a memory leak in Array#{uniq, uniq!, compact, compact!,
    select, select!, keep_if}.
  • [iOS] Fixed a bug where it would trigger a crash when Ruby method which has
    5 or more arguments will be called from Objective-C code in arm64 device.
  • [OSX] Updated Edit menu to include items generated by Xcode. Thanks to
    Hwee-Boon Yar for the patch (pull request #187).
  • [Android] Introduced app.manifest, which makes it possible to directly
    manipulate the contents of the AndroidManifest.xml file from the Rakefile.
    Read the documentation in the “Providing Custom Values” section of the
    Android Project Management guide on the RubyMotion website. Thanks to
    Daniel Brooker for the patch.
  • [Android] Added String#{[], slice}.
  • [Android] Fixed a bug where projects with an XML file in the ‘resources’
    directory would not compile correctly.
  • [Android] Fixed a bug where Object#instance_eval would crash when targeting
    old versions of Android (below 14).
  • [Android] Fixed a bug where Ruby methods and blocks where limited by the
    number of arguments they could accept.
  • [Android] Fixed a bug where Hash would not include Enumerable.
  • [Android] Fixed a bug where Ruby Hash methods (ex. #[]) would not be
    available on Java *Map objects.
  • [Android] Fixed a bug where Hash objects with a default Proc (ex. created
    with Hash.new {}) would not dispatch the Proc when a key isn’t found.
  • [Android] Fixed a bug where Ruby String methods were not available on
    java.lang.String objects.
  • [Android] Fixed a bug where passing java.lang.String objects to Ruby
    String methods expecting String arguments would cause a runtime crash.

RubyMotion tip by Austin Seraphin


Application Verification Failed might simply mean the app identifier differs from the one in the provisioning profile.

Android tip of the week by Darin Wilson


When you start learning a new platform, you spend a lot of time looking at error messages, and it’s not always immediately clear what they mean. Here’s one that tripped me up recently.

Let’s say you’re creating an Activity and you want to use the new Toolbar widget. You might try something like this:

class MainActivity < Android::App::Activity
  def onCreate(savedInstanceState)
    super
    @toolbar = Android::Widget::ToolBar.new(self)
  end
end

If you try to run this code, you’ll get an error:

E/AndroidRuntime(11723): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yourcompany.myapp/com.yourcompany.myapp.MainActivity}: com.rubymotion.NameError: uninitialized constant `Android'

What the…? Why can’t the compiler find the Android package? Shouldn’t that be standard? Did I forget to require something in my Rakefile? What’s going on here??

As it turns out, the Android constant is fine – it’s ToolBar that’s wrong: it should be Toolbar with a lower-case “b”. When you’ve got a chain of constants strung together with :: and there’s a problem anywhere in the chain, the compiler only complains about the first element in the chain, no matter where the error may actually be.

So if you’re translating a Java package path into Ruby, and you get a NameError on something surprising like Com or Android, check the entire constant chain: the problem is probably somewhere further down the path.

Sponsor


My company InfiniteRed sponsors this newsletter by allowing me the time to work on it every week and hosting everything.

Contact us if you ever need help working on a project, mentoring, or other development services . We specialize in RubyMotion and have an awesome team.

image

App of the Week


image

Vooruit met tellen – by Koop Otten – “Becoming a higher level!
Through a clever game that adapts to the child’s child playfully level goes up.”

Gems:

  • Bubble-wrap
  • nano-store //local database
  • Afmotion // to communicate with API
  • sugarcube // animations

Pods:

  • Lookback! // Used a lot while testing! Awesome tool!
  • cocos2D // For the audio. ( gives conflicts with new RubyMotion version though 🙁 )
  • UIView-AutoLayout
  • And HockeyApp for seeding to our testers


If you have any tips, blog posts, or comments, please send emails to todd@infinitered.com