Jan 9, 2013

Salesforce Mobile SDK - Eclipse Setup and Android App


This is the fourth and final post of the Salesforce Mobile SDK Series.  Here's what you've missed if you're new to the series:
  1. Salesforce Mobile SDK - Introduction
  2. Salesforce Mobile SDK - Mobile Visualforce Page and the Connected App
  3. Salesforce Mobile SDK - Xcode Setup and iOS App
In the last post, we set up Xcode for iOS development using the Visualforce Page we created in part 2. In this post, we'll do the same for Android within Eclipse.

1)  If not already installed on your machine, download Eclipse (I'm using Classic 4.2.1) here:  http://www.eclipse.org/downloads/

2)  Locate and download installer_r21-windows.exe under the "Download for Other Platforms" sections here:  http://developer.android.com/sdk/index.html

3)  After you've downloaded the Android SDK installer, execute it to begin the installation wizard steps.  A check will be performed to ensure you have a JDK installed (I had v1.7 installed).

4)  When the installation has completed, make sure a check is in the box to "Start SDK Manager..." and then click on the "Finish" button.



5)  When the SDK Manager window opens, select the "Tools" folder, the latest version of Android (4.2 below), along with any others you want to install at this point and click on the "Install Packages" button.  Click on the "Accept All" radio to accept the terms of all packages and wait for the install to complete.



6)  After installation is completed, set up a new Virtual Device by clicking on "Tools" and then "Managed AVDs..."

7)  Click on the "New...' button, provide the following details, and click on the "OK" button


8)  Download and install Git from:  https://help.github.com/articles/set-up-git

9)  Clone the Salesforce Mobile SDK by opening a command prompt window and entering: git clone git://github.com/forcedotcom/SalesforceMobileSDK-Android.git

10)  Open Eclipse

11)  Choose a new location for your workspace and click on the "OK" button



12)  If prompted, although you already downloaded them, choose "Install new SDK" and check "Install the latest available version of the Android API's."  Choose an option in regards to sending your user usage to Google, and then choose "Accept All" and then click on the "Install" button

13)  Click on File --> Import...


14)  General --> Existing Projects into Workspace



15)  First import the SalesforceSDK from ../Downloads/SalesforceMobileSDK-Android/native/SalesforceSDK (your location may vary, depending on your Git configuration)




16)  Then import the VFConnector sample app from ../Downloads/SalesforceMobileSDK-Android/hybrid/SampleApps/VFConnector (your location may vary, depending on your Git configuration)



17)  Navigate to your Project --> Assets -->  WWW folder and edit the bootconfig.js file as we did in part 3/4 to point the project to our Visualforce page:



18)   Click on the "Run" button and choose the AVD we created in Step 7.  The emulator should start up within a few moments if not already running.


19)  Unlock the device and depending on the state of the installation, you'll either find your app under the App drawer menu or it will pop open automatically.


There you have it!  Quick and easy mobile applications, based off of a single Visualforce page, for two platforms with minimal coding.  The most difficult part of the process for those without mobile app development experience is the configuration of the environment.  Something always goes wrong and a little Googling will help in most cases.  Hopefully you've found these four blog entries helpful as a quick introduction to the Salesforce Mobile SDK.  Good luck!