Skip to content

Instantly share code, notes, and snippets.

@alxjrvs
Last active August 29, 2015 14:06
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alxjrvs/4b73771294ea25feb2f7 to your computer and use it in GitHub Desktop.
Save alxjrvs/4b73771294ea25feb2f7 to your computer and use it in GitHub Desktop.
Android-motion Gotchas!

#Two Gotcha's In the @RubyMotion getting started guide for Android

##The NDK Does not Support API level L I got this error when I tried to rake device for the first time.

ERROR! It looks like your version of the NDK does not support API level L. Switch to │  7       structure: Structure
a lower API level or install a more recent NDK.

luckily, there's an easy fix.

  1. Go to the NDK index and download the "64 bit, 64 Target link" for MacOs. You should have used the "64bit, 32bit target" if you were following the instructions in the getting started. Because of size limitations, they hid the Android L headers in the 64 Bit version, so we're just going to steal them!
  2. Once that is downloaded, unzip the new NDK and navigate to /platforms. You should see the Android-L folder there.
  3. Copy that Android L folder into the local NDK directory (if you followed the example in the guide, it will be ~/android-rubymotion/ndk/platforms/)

That's it! Your NDK now knows how to read the new and shiny version of android.

(Many Thanks to @MarkVillaCampa for tweeting about this earlier!)

Specifying Target SDK

Then I got this error.

ERROR! Cannot install an app built for API version L on a device running API version 19

Apparently, the generator defaults to targeting the latest version of Android, and there are no phones that come stocked with L yet. No worries!

  1. Make sure you've got all the SDK's downloaded that you want to work with. The Getting started guide goes over that here.
  2. navigate to and open the Rakefile in your project.
  3. in the Motion::Project::App.setup block, assign the api_version attribute on the app object, like so:
```
Motion::Project::App.setup do |app|
  app.name = "MyAndroidMotionApp"
  app.api_version = "19"
end
```

Where '19' is the SDK of the device you are targeting.[1]

  1. run rake device and see your app boot up on the phone. Congrats!

You can see what else you can configure by running rake config, which provides lots of neat options.

Good luck, Robots!

Alex Jarvis, Terrible Labs

[1] Go here to compare numbers to version names.

@lrz
Copy link

lrz commented Sep 18, 2014

Thanks so much!

The NDK issue is problematic, in the past L headers used to be part of the package. We will have a look and see how we can support L automatically.

The second issue is less an "issue": by default RubyMotion will target the latest version of Android it supports (here being L), so your device has to run L. Maybe it would be better to only target the latest stable release instead?

@alxjrvs
Copy link
Author

alxjrvs commented Sep 18, 2014

I would agree on that. It's definitely less of a real bug or issue, but definitely tripped up my co-workers who were less familiar with the android architecture.

@alxjrvs
Copy link
Author

alxjrvs commented Sep 18, 2014

That said, I see no way to differentiate between the target and the minimum target, which is at least a bit confusing.

@jpdicosola
Copy link

Thanks! This has helped a lot.

Is anyone else getting errors when trying to run the Conference sample code? It seems that referencing jar files in the vendor folder is failing.

can't open BridgeSupport full file at path `vendor/android-support-v4.jar.bridgesupport': Error Domain=NSXMLParserErrorDomain Code=73 "Line 353: Unescaped '<' not allowed in attributes values

@rasmusmaagaard
Copy link

Regarding the Conference sample code I had the same problem when using Java 8. When I switched to Java 6 the generated .bridgesupport files was working correctly (they are not removed by a rake clean, so your have to delete them manually after switching java version).

@jpdicosola
Copy link

I had the same issue but with Java 7. Removing and using Java 6 worked perfectly. Thanks!

@phoet
Copy link

phoet commented Oct 16, 2014

gotchas all the way down 😄

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