Build for Android
From RadPHP XE2 Documentation
This page covers deployment of mobile applications for Android, either for debugging purposes or for final releases.
Contents |
Wizard for Phonegap
Warning: You need to setup Android SDK and additional software first.
Deployment Setup
- Go to Tools > Wizard for PhoneGap.
- On the Welcome page, choose Android as Target Device and click Next.
- On the Application Setup page:
- Set Index page to the page to be displayed first when users run your application.
- In the Application name field, type your application’s name.
- In the Company name field, type the name of your company.
- Click Next.
- On the Android Graphics page, you can setup icons and splash screens for your application.
- To choose an image file for a field:
- Click ….
- Go to image’s location, and select it.
- Click OK.
- Click Next.
- To choose an image file for a field:
- On the Choose Destination Folder page:
- 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.
- Debug to sign the application with a default key. This is recommended when debugging your application.
- 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.
- Click ….
- Go to folders location, and click OK.
- Click Next.
- Choose a compilation mode:
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 can not 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:
- On the Keystore Selection page:
- Check Using existing keystore.
- Enter the Location of your keystore, or click … button and find it in your filesystem.
- Enter the Password for the keystore.
- Click Next.
- On the Key Alias Selection page:
- Choose an Alias from the .keystore. Open the drop-down menu to get the list of available aliases.
- Enter the Password for that alias.
- Click Next.
If you do not have a keystore yet:
- On the Keystore Selection page:
- Check Create new keystore.
- Enter the Location of your new keystore, or click … button and find it in your filesystem. For example: C:\Android\main.keystore.
- Enter the Password for the keystore, and enter it again in the Confirm field.
- Click Next.
- 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 and run your application.
Build and Run
On the Export page, wait for all the files to be exported, and then click Next.
Outside the wizard, manually copy any external resources included in your application (like image files) into the destination folder, inside the www directory. Check this video tutorial (around minute 6:25).
- If you want to run your application on an emulator:
- On the Run your app page:
- Select Emulator.
- In the drop down menu, choose your emulator of choice.
Note: If you did not setup an Android Virtual Device yet, open Android SDK Manager (Start > All Programs > Android SDK Tools > SDK Manager) and follow these instructions.
- Click Next.
- On the Run your app page:
- If you want to run your application on a real device:
- Make sure you have the device correctly connected to your computer.
- On the Run your app page:
- Select Real device.
- Click Next.
- If you just intended to build your application and do not want to run it, just click Cancel to exit the wizard. Check where the final binaries are located.
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 running the Wizard for PhoneGap, your application’s 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.
Compile on Eclipse
Warning: You need to setup Eclipse and ADT plugin first.
Import Your Project
When you build your application from RadPHP, which generates a PhoneGap folder, an Eclipse project file is included in this folder so you can open your project with Eclipse:
- Go to File > New > Project... > Android > Android Project, and click Next.
- On the next dialog:
- Enter a Project Name.
- Select Create project from existing source.
- On the Location field, use the Browse button to set the path to the PhoneGap folder you exported with RadPHP.
- Click Next.
- On the next page:
- Make sure your desired Android version is checked as Build Target.
- Click Finish.
Now you are ready to run your project or just compile it.
Run Your Application
To run your application, go to Run > Run As > Android Application. Your application will be compiled an launched in either a virtual device or a real device, depending on your Eclipse settings.
Compile Your Application
Before you build a public version of your application:
- Open AndroidManifest.xml file.
- Go to Application > Application Attributes.
- Set Debuggable attribute to false.
- Go to File > Save to save the change.
Now, you will open Export Android Application dialog in order to build your application. Right-click you project folder in Package Explorer and:
- If you want to sign your application, go to Android Tools > Export Signed Application Package…, and follow these steps.
- If you do not want to sign your application, go to Android Tools > Export Unsigned Application Package…, and follow these steps.
Warning: Unsigned applications can not be installed on Android devices. More information in Android Official Documentation.
Compile Your Application Signed
- On the Export Android Application page, click Next.
- On the next page:
- If you have already a .keystore file to sign your application:
- On the first page:
- Leave the default choice selected, Use existing keystore.
- Click Browse…, go to your .keystore file, select it and click OK.
- Type your password in Password field.
- Click Next.
- On the next page:
- Choose an alias.
- Type alias’ password in Password field.
- Click Next.
- On the first page:
- If you do not have a .keystore file yet:
Note: .keystore files contain one or several signatures you might use to sign Android applications.
- On the first page:
- Choose Create new keystore.
- Click Browse…, navigate to the location where you want to save your new .keystore file and then click OK.
Warning: Save your .keystore file in a safe place, you should use it to sign any application you publish.
- Type your password in Password field.
- Type your password again in Confirmation field.
- Click Next.
- On the next page:
- Fill the form with your data. You need to fill at least these fields: Alias, Password (and Confirm), Validity (25 years is recommended) and First and Last Name.
Note: This data will be used for the initial signature of your new .keystore file.
- Click Next.
- Fill the form with your data. You need to fill at least these fields: Alias, Password (and Confirm), Validity (25 years is recommended) and First and Last Name.
- On the first page:
- If you have already a .keystore file to sign your application:
- On the next page, click Browse…, go to the location where you want to save your application’s .apk file, and click OK.
- On the last page, click Finish.
Compile Your Application Unsigned
Note: Steps below take place once you have opened Export Android Application dialog.
- Choose the location where you want to save your application’s unsigned .apk file.
- A warning dialog will pop up to tell you how to sign your application later. Click OK.