What goes into an AIR Native Extension for Android?

Opt In Image
Early bird offer on the ANE eBooks

 

Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.

 

 

  • step-by-step guide to making your iOS extension in under an hour
  • library for data conversion between ActionScript and native code
  • tutorials
  • infographics
  • code included

So you are an Android guy. Or gal. Or, you are an ActionScript person, who wants to expand to Android. Same difference.

Here is a bit of prerequisite information, in case you need it:

Next, let us see the ingredients that you have to provide for an ANE and those that are provided for you.

You will have to make two libraries:

  • an AIR library, compiled as a .swf file;
  • a native Java library, compiled as a .jar file.

The communication by these two libraries is handled by another component, which Adobe  has provided for you:

  • the AIR Java API.

The AIR library

Your AIR library is a Flex library project, which contains an instance of flash.external.ExtensionContextExtensionContext is the class that provides an ActionScript interface for you to make calls to and receive messages from your Java .jar library.

The AIR Java API

The AIR Java API is the layer that sits between your ActionScript and Java code. It ‘translates’ the ActionScript calls you make to ExtensionContext into Java and allows you to send events and data from Java back to ActionScript.

The AIR Java API is part of Adobe’s AIR SDK and is implemented as a .jar library, which you include in your native library project (see below).

The native library

Your native library will be a .jar that uses the AIR Java API – in red on the diagram below. It can also include any number of Android SDK or third party libraries.

Android native library

The ANE package

In order to be used as a native extension, your AIR and your native libraries need to be packed in an .ANE file. Adobe’s ADT command line tool does that for you. We will see how in Recipe for packaging an ANE.

Android ANE structure

What else?

Over to you

What problems have you run into on Android that require native extensions? Share in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">