Creating an APK package
To create
an APK package, use the ADT package command, setting the target type
to apk for release builds, apk-debug for debug builds,
or apk-emulator for release-mode builds for running on an
emulator.
adt -package
-target apk
-storetype pkcs12 -keystore ../codesign.p12
myApp.apk
myApp-app.xml
myApp.swf icons
Type the entire command on a single
line; line breaks in the above example are only present to make
it easier to read. Also, the example assumes that the path to the
ADT tool is on your command-line shell’s path definition. (See Path environment variables for help.)
You must run the command from
the directory containing the application files. The application
files in the example are myApp-app.xml (the application descriptor
file), myApp.swf, and an icons directory.
When you run the
command as shown, ADT will prompt you for the keystore password.
(The password characters you type are not displayed; just press
Enter when you are done typing.)
Note: (AIR 3.7 and higher)
By default, ADT packages a captive copy of the AIR runtime with
your Android app. To force ADT to create an APK that uses an external
runtime, set the AIR_ANDROID_SHARED_RUNTIME environment
variable to true.
When you bundle the
runtime with your app, this captive runtime is used exclusively
by your application.
The benefits of packaging with a captive
runtime include:
Produces a self-contained application
Application is isolated from runtime updates
Enterprises can certify the specific application and runtime
combination
No separate runtime download and install is required
Creating an APK package for an application that uses native extensions
To create an APK package for an
application that uses native extensions, add the -extdir option
in addition to the normal packaging options. This option specifies
the directory that contains the ANE files that the application uses.
For example:
adt -package
-target apk
-storetype pkcs12 -keystore ../codesign.p12
myApp.apk
myApp-app.xml
-extdir extensionsDir
myApp.swf icons
Creating an APK package that includes its own version of the AIR runtime
To create an APK package that contains
both the application and a captive version of the AIR runtime, use
the apk-captive-runtime target. This option specifies
the directory that contains the ANE files that the application uses.
For example:
adt -package
-target apk-captive-runtime
-storetype pkcs12 -keystore ../codesign.p12
myApp.apk
myApp-app.xml
myApp.swf icons
Possible drawbacks of this technique
include:
Note: When
you bundle the runtime, ADT adds the INTERNET and BROADCAST_STICKY permissions
to your application. These permissions are required by the AIR runtime.
Creating a debug APK package
To create
a version of the app that you can use with a debugger, use apk-debug as
the target and specify connection options:
adt -package
-target apk-debug
-connect 192.168.43.45
-storetype pkcs12 -keystore ../codesign.p12
myApp.apk
myApp-app.xml
myApp.swf icons
The -connect flag tells the AIR runtime
on the device where to connect to a remote debugger over the network.
To debug over USB, you must specify the -listen flag
instead, specifying the TCP port to use for the debug connection:
adt -package
-target apk-debug
-listen 7936
-storetype pkcs12 -keystore ../codesign.p12
myApp.apk
myApp-app.xml
myApp.swf icons
For most debugging features to work,
you must also compile the application SWFs and SWCs with debugging
enabled. See Debugger connection options for a full description of the -connect and -listen flags.
On
Android, the app must also have permission to access the Internet
in order for it to connect to the computer running the debugger
over the network. See Android permissions.
Creating an APK package for use on an Android emulator
You
can use a debug APK package on an Android emulator, but not a release mode
package. To create a release mode APK package for use on an emulator, use
the ADT package command, setting the target type to apk-emulator :
adt -package -target apk-emulator -storetype pkcs12 -keystore ../codesign.p12 myApp.apk myApp-app.xml myApp.swf icons
The
example assumes that the path to the ADT tool is on your command-line shell’s
path definition. (See Path environment variables for help.)
Creating an APK package from an AIR or AIRI file
You
can create an APK package directly from an existing AIR or AIRI
file:
adt -target apk -storetype pkcs12 -keystore ../codesign.p12 myApp.apk myApp.air
The
AIR file must use the AIR 2.5 (or later) namespace in the application descriptor
file.