Jeff Ward
Mobile, Web, Linux, and other cool Tech
find me at
Simbulus Consulting Stack Overflow Hacker Rank GitHub LinkedIn Twitter Google Plus

Setup AIR 3.9 SDK On Ubuntu 12.04

Jan 8, 2014 #Actionscript#Mobile#Linux#AIR#Ubuntu

This post includes all the setup necessary to get started using the AIR SDK under Ubuntu linux. While the instructions are fairly generic and should be applicable in many circumstances, I used Adobe AIR SDK 3.9 and a fresh install of Ubuntu 12.04.3 64-bit. I like LTS releases and developers will usually be working in 64-bit environments with lots of RAM.

Note that AIR SDK 4.0 is currently in beta, and I've tested that with wine 1.7 the halfmoon compiler does improve IPA packaging time nicely. I'll do an update to this post when AIR SDK 4.0 and Ubuntu 14.04 are out.

Install AIR SDK 3.9 and Wine 1.7

First things first, the AIR SDK is the primary goal, and it requires wine to run. Wine 1.7 is preferred since it'll be compatible with the halfmoon compiler in AIR 4.0, but I've used wine 1.4 without trouble.
cd /opt/
sudo mkdir air_sdk_3.9
cd air_sdk_3.9
sudo chown `whoami`:`whoami` .
wget http://airdownload.adobe.com/air/win/download/latest/AIRSDK_Compiler.zip
unzip AIRSDK_Compiler.zip
export AIR_HOME=/opt/air_sdk_3.9
echo "export AIR_HOME=/opt/air_sdk_3.9" >> ~/.bashrc
That's it for the AIR SDK. For wine, we'll use the nice ppa:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7 winetricks
This one may not be critical, but I found that it enabled some networking (URLLoader or Socket, I don't recall exactly) calls that weren't working otherwise:
winetricks wininet
And if you've used wine before, you know it can be a tad too verbose in its superfluous debug messages. Quash those annoying messages with the following:
export WINEDEBUG=fixme-all
echo 'export WINEDEBUG=fixme-all' >> ~/.bashrc

Install Java if you don't already have it

The mxmlc compiler requires Java on linux, and the adt packager requires Java on Windows (wine). Unfortunately Oracle doesn't easily let you script this install process because they want you to read their licensing terms. But go to the jdk download page, check the "Accept License Agreement" button, and download the Linux x64 .tar.gz file (jdk-7u45-linux-x64.tar.gz) and the Windows x86 file (jdk-7u45-windows-i586.exe).

When the downloads complete, continue:

If you already have Java installed in linux, you can skip this step. To setup the linux JDK you just downloaded:
cd /opt
sudo mkdir jvm
cd jvm
sudo chown `whoami`:`whoami` .
tar -xvzf ~/Dowloads/jdk-7u45-linux-x64.tar.gz
export JAVA_HOME=/opt/jvm/jdk1.7.0_45
export PATH=$PATH:$JAVA_HOME/bin
echo 'export JAVA_HOME=/opt/jvm/jdk1.7.0_45' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
To setup the Windows JDK under wine, simply run the below command and leave the default settings for all questions in the setup GUI:
cd ~/Downloads
wine jdk-7u45-windows-i586.exe

Test compilation and simulation

You're ready to compile and simulate at this point. Install git and grab my test air app setup from Github:
sudo apt-get install git
cd ~
mkdir dev
cd dev
git clone https://github.com/jcward/BaseAIRAppLinux.git
cd BaseAIRAppLinux
./compile.sh
# should complete successfully with:  1118 bytes written ...
./simulate.sh
# should open adl simulator window with "Hello World" TextField

ADL Simulator running in Ubuntu

Wine / Simulator issues

If you get an error about gnome-keyring-pkcs11.so when trying to simulate and your simulation still works, just ignore it. If it's causing problems, you can try these answers by andy.holmes or vaab. But beware, I tried installing libp11-kit-gnome-keyring:i386 in Lubuntu 13.10 64-bit, and it caused my simulator to crash. So I uninstalled it. vaab's answer worked in Ubuntu 12.04.3 64-bit, but not in Lubuntu 13.10 64-bit.

If you have problems with audio / pulseaudio, try installing these audio-related packages. This cleared up a crash issue related to libpulse.so in pa_mainloop_poll:
sudo apt-get install alsaplayer-daemon alsa-oss alsaplayer-xosd  pulseaudio-esound-compat oss-compat

Fast compile iterations

Of course, you want your compiles to go lightning fast with a memory-resident compilation process (like in Flash Builder) right? You're prepared to be cogniscent about a memory-hungry compiler in a daemon process, killing it when it gets out of hand or causes weird compilation errors, right? If you're answer was "For lightning fast compiles, I'll pay attention!" then excellent! Install my ascshd project (which also requires Ruby):
cd ~/dev
sudo apt-get install ruby1.9.3
git clone https://github.com/jcward/ascsh.git
cd ascsh
./install.sh
Now check out how my test app's compile.sh script detects and uses it, and try it out:
cd ~/dev/BaseAIRAppLinux
cat compile.sh
# notice if [ if $AIR_HOME/bin/ascshd ]
./compile.sh
# First compile starts ascshd, takes ~2 seconds
./compile.sh
# Second compile takes ~1 seconds
./compile.sh
# Third compile takes <1 seconds

And finally, packaging for devices

Packaging uses Wine, ADT (and by extension Windows Java). This is all already installed. Just give it a try in my test app:

Packaging for Android

cd ~/dev/BaseAIRAppLinux
./compile.sh
./package_android.sh
ADT has built-in support for install apps, but I've never had great luck with it. Instead, I install ADB for linux. You could also install the entire Android SDK, but that's a lot of downloads. If all you want is to install you APK file over USB (you can also install it via email or web server), then just drop the 64-bit linux adb utility somewhere on your path:
cd /usr/local/bin
sudo wget http://jcward.com/adb
sudo chmod a+x adb
cd ~/dev/BaseAIRAppLinux
adb devices
# Should show your device plugged in via USB, if not, try:
sudo adb kill-server
sudo adb start-server
# Then install your app:
adb install -r Main.apk

Packaging for Apple iOS Devices (iPhone, iPad, iPod, etc)

Packaging for iOS will require an Apple developers account, a mobile provisioning profile, and a certificate. Generating these is beyond the scope of this document, but there are good tutorials out there. Once you have the necessary files in place update the package_ios.sh file with your provision and cert files, and cert password. Then you'll be able to produce .ipa packages:
cd ~/dev/BaseAIRAppLinux
./compile.sh
./package_ios.sh
There is a sweet linux package for installing .ipa files onto your devices over USB. Install and use it like so:
sudo apt-get install ideviceinstaller
ideviceinstaller -i Main.ipa
I've seen it return some odd errors on occasion (about missing plist files and whatnot), but usually the app installs anyway.

Feedback

Please let me know in the comments if you run into trouble. Feel free to contribute to BaseAIRAppLinux - I intend to get lots of things in like example app icons, app.xml updates like retina support and android permissions, improved build scripts, perhaps a Starling example fork, etc.

There are more useful development commands listed in my post, Adobe AIR Mobile Development On Linux, but note that using the Flex SDK is no longer necessary as ascshd provides fast builds.

Most of all, enjoy an entirely FREE development workflow on an entirely FREE OS using an awesome language with amazing cross-platform reach!
comments powered by Disqus