I am trying to build an Android Hybrid Remote app using the Salesforce Mobile SDK. I have an iOS Hybrid Remote app working, so I expected create the app, set the config (consumer key, oauth redirect uri, start page) to match, and get a working app in the emulator. So far I am unable to run the app. Here's a rundown of steps taken and problems encountered.
I am trying to follow these instructions from developer.salesforce.com on a Mac. I will note that these instructions seem somewhat incomplete, and I've already solved a few issues not covered by the tutorial. I started by installing the Android SDK; I chose to install Android Studio as it includes the command line tools as well as an emulator (Nexus_5_API_21_x86). I also installed the forcedroid package via npm. I then used the forcedroid create
command from the tutorial; I just changed the apptype to hybrid_remote
and added the --startpage
param.
The first time I ran this, I got the following error:
Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.
<stacktrace>
I followed those instructions and installed android sdk version 19, and tried again. This time, I got success. I will note that the forcedroid
output included instructions for opening the project in eclipse, however, I stuck to the tutorial, which has steps for running the app from a command line. I did update www/bootconfig.json to match the settings from my working ios hybrid project (consumer key, oauth redirect uri, start page).
The next step in the tutorial is:
To build the new application, type the following commands at the command prompt:
cd your_project_directory $ANDROID_SDK_DIR/tools/android update project -p . <id>
where ANDROID_SDK_DIR points to your Android SDK directory.
This failed ("Error: . is not a valid project (AndroidManifest.xml not found)"), so I tried running from ./platforms/android
, where lives the missing manifest. This gave a message about subprojects, so I added --subprojects.
The next step in the tutorial calls for you to "run an emulator" (which I puzzled through), and run ant installd
; the command output indicated that it couldn't find the binary to install. A call to ant
gave other targets including debug
, so I tried ant debug
, and now I'm getting build errors of the form:
[snip] -pre-compile: [echo] Set jars path to: /Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SmartSync/ant-build/classes.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SmartStore/ant-build/classes.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SalesforceSDK/ant-build/classes.jar:/Users/jclark/dev/shdroid/platforms/android/CordovaLib/ant-build/classes.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SalesforceSDK/libs/android-junit-report-1.5.8.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SalesforceSDK/libs/volley_android-4.4.2_r2.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SmartStore/libs/guava-18.0.jar:/Users/jclark/dev/shdroid/platforms/android/libs/gcm.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SalesforceSDK/libs/apache-mime4j-0.7.2.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SmartStore/libs/sqlcipher.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SalesforceSDK/libs/httpcore-4.3.2-modified.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SmartStore/libs/commons-codec.jar:/Users/jclark/dev/shdroid/plugins/com.salesforce/src/android/libs/SalesforceSDK/libs/httpmime-4.3.2.jar:/Users/jclark/dev/shdroid/platforms/android/libs/android-support-v13.jar -compile: [javac] Compiling 12 source files to /Users/jclark/dev/shdroid/platforms/android/bin/classes [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. [javac] /Users/jclark/dev/shdroid/platforms/android/src/com/plugin/gcm/PushPlugin.java:8: error: cannot find symbol [javac] import org.apache.cordova.CallbackContext; [javac] ^ [javac] symbol: class CallbackContext [javac] location: package org.apache.cordova [javac] /Users/jclark/dev/shdroid/platforms/android/src/com/plugin/gcm/PushPlugin.java:9: error: cannot find symbol [javac] import org.apache.cordova.CordovaInterface; [javac] ^ [javac] symbol: class CordovaInterface [javac] location: package org.apache.cordova [javac] /Users/jclark/dev/shdroid/platforms/android/src/com/plugin/gcm/PushPlugin.java:10: error: cannot find symbol [javac] import org.apache.cordova.CordovaPlugin; [snip more of same]
And here I'm stuck. I believe that npm install forcedroid
should have installed the Cordova pieces needed, but I've also run npm install -g cordova
recently. Based on the error above that requested API 19, I tried running android update project -p . -t android-19
and then reran build clean
and build debug
, but no luck.
What am I missing? Is there another step I've missed? In case it isn't obvious,I'm brand new to Android SDK dev, so please ask any "obvious" questions.
update I've picked apart the jars path shown in the compile error above, and /Users/jclark/dev/shdroid/platforms/android/CordovaLib/ant-build/classes.jar
doesn't exist, nor does /Users/jclark/dev/shdroid/platforms/android/CordovaLib/ant-build/
. /Users/jclark/dev/shdroid/platforms/android/CordovaLib
does, and contains an AndroidManifest.xml, but ant debug
doesn't create the missing classes.jar
. I'm pretty sure this is the basis of the issue, but not sure how to proceed.