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
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:
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 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.