Android Deployment

From HTML5 Builder
Jump to: navigation, search

This page covers deployment of mobile applications for Android devices.

Export your Project

Generation

Go to Home > Deploy to Mobile, and follow these steps:

  1. On the Welcome page, choose Android as target device and click Next.
  2. On the Application Setup page:
    1. Set Index page to the page to be displayed first when users run your application.
    2. In the Application name field, type your application’s name.
    3. In the Company name field, type the name of your company.
    4. Click Next.
  3. On the Android Graphics page, you can setup icons and splash screens for your application.
    1. To choose an image file for a field:
      1. Click .
      2. Go to image’s location, and select it.
      3. Click OK.
    2. Click Next.
  4. On the Choose Destination Folder page:
    1. Choose a compilation mode:
      • Debug to sign the application with a default key. This is recommended when debugging your application.
        Note: If you want to run your debug application on a real device, you must set your device to debug mode. For additional information, check developer.android.com/guide/developing/device.html.
      • Release to properly sign the application, which is a must for deployment.
    2. Optionally, change destination folder:
      Note: The folder you choose will be where all files and folders will be generated. You might want to create a new folder for your build.
      1. Click .
      2. Go to folders location, and click OK.
    3. Click Next.

Now, depending on which compilation mode you chose before, further steps will be different. For debugging builds, you can already build your application and run it; for a final build, you will need to follow some additional steps.

Note: You cannot install your application in debug or release mode over an existing version on the opposite mode. For example, if you try to install your application in release mode (signed) on a device where you already installed the same application in debug mode, Android will not allow it. You need to remove your application first.

Release Setup

If you already have a keystore:

  1. On the Keystore Selection page:
    1. Check Using existing keystore.
    2. Enter the Location of your keystore, or click button and find it in your filesystem.
    3. Enter the Password for the keystore.
    4. Click Next.
  2. On the Key Alias Selection page:
    1. Choose an Alias from the .keystore. Open the drop-down menu to get the list of available aliases.
    2. Enter the Password for that alias.
    3. Click Next.

If you do not have a keystore yet:

  1. On the Keystore Selection page:
    1. Check Create new keystore.
    2. Enter the Location of your new keystore, or click button and find it in your filesystem. For example: C:\Android\main.keystore.
    3. Enter the Password for the keystore, and enter it again in the Confirm field.
    4. Click Next.
  2. On the Key Creation page, fill the form with your data, and click Next. You need to fill at least these fields: Alias, Password (and Confirm), Validity (10000 days, around 25 years, is recommended) and First and Last Name.
    Note: This data will be used for the initial signature of your new .keystore file.

Now, you can continue with the steps to build your application.

Configuration

On the Export page, your PhoneGap folder will be exported to the destination folder as www, and archived as a Your Application.zip file there too. Wait for the process to finish.

There are some things you might want to do on the www folder before you continue, some of the possibilities are listed below.

Once you are ready, if you changed anything on the www folder, generate a new Your Application.zip archive with its contents (there are several tools you can use for that task).
Warning: You must create the archive from the contents of the www folder, not from the folder itself.

External Resources

Outside the Wizard for PhoneGap, you must manually copy any external resources included on your application (for example, image files) into the destination folder, inside the www directory.

Screen Orientation

You can define a specific device orientation to be used for your application, so it doesn’t rotate. Edit your AndroidManifest.xml file (inside the www directory) and, on the <activity> tag, set the android:screenOrientation property to the name of the orientation you want to force for your application.

For example, if you want your applications to be always displayed on a portrait orientation: <activity android:screenOrientation="portrait">.

Preparations for a Release

If you are deploying a release of your application you want to upload to the Android Market, you must also edit your AndroidManifest.xml file (inside the www directory):

  • Set the proper values for the following fields: android:versionName, android:versionCode. For example: android:versionName="1.0" and android:versionCode="1" for your first application. Read Android Documentation for additional information.
  • Define the right features and permissions your applications requires. Depending on which ones you define, your application will be filtered on the Market, so only request those your application actually needs. You can remove some of the default permission requests, but keep at least INTERNET and READ_PHONE_STATE.

Build your Application

Once the PhoneGap project folder is ready, you can build the final application either remotely, using the PhoneGap Build service, or locally. If your system is configured to build Android applications, you will be given both choices. Else, the PhoneGap Build service will be selected for you.

See PhoneGap Build for instructions on how to build your application remotely, or continue reading to build it locally.

Local Build

Note: You must prepare your system to build your applications locally. See Android Setup.

Continue one of the ways below depending on what you plan to do:

  • If you want to run your application on an emulator:
    1. On the Run your app page:
      1. Select Emulator.
      2. In the drop down menu, choose your emulator of choice.
        Note: There should be at least one emulator, my_avd, which is created when installing the Android Tools. You can manage and create additional emulators from the Android SDK Manager (Start > All Programs > Android SDK Tools > SDK Manager), see the instructions here.
      3. Click Next.
  • If you want to run your application on a real device:
    1. Turn on "'USB Debugging'" on your device, go to Settings > Applications > Development and enable USB debugging. It is located at Settings > Developer options from Android 4.0 on.
    2. Make sure you have the device correctly connected to your computer.
    3. On the Run your app page:
      1. Select Real device.
      2. Click Next.
  • To get your application to build, you will need to choose one of the previous options. You can, for example, choose the emulator, and then exit the wizard once the application is build. Check where the final binaries are located.
  • If you just want to export your PhoneGap project folder, it is already done. You can click on Cancel to exit the wizard.

If you choose to run your application in an emulator, once the emulator has been completely started, your application might not start right away. Android launcher has a timeout, and on some systems (and specially on virtual machines) it will not be enough. If that is your case, in the Wizard for PhoneGap, click Previous and Next again. That way, your application will be built again and will run on the device right away. Since it is already running from your previous attempt, timeout will not be a problem this time.

Once your see your application running either on the emulator or on your real device, you can click Finish in the Wizard for PhoneGap.

Binaries Location

After building your application locally, its binary (.apk file will be saved in the bin folder inside the destination directory you chose from the wizard. There you will find an unsigned version of your application (Your Application-unsigned.apk) which you can install on devices in debug mode, and if you chose Release option in the wizard, you will also find a signed version (Your Application-release.apk) you can deploy to your customers.

Assuming you signed your application and got your Your Application-release.apk file, you can now publish it to the Android Market. Information on how to do that can be found at Android Developer Guide: developer.android.com/guide/publishing/publishing.html.

Help Resources

Video Tutorials

See Also

Personal tools