2

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.

2

Based on the errors described above, can you confirm did you run this command after you installed the Mobile SDK?

./install.sh

I think it's missing on the link you quoted but this is the first step that you need to do and it's mentioned on Mobile SDK repo page.

  • No, the docs you reference say to do that, "After cloning the SalesforceMobileSDK-Android project from github." I didn't clone from github, I installed the forcedroid package via npm (see prior paragraph in docs). There is no install.sh in either the created project directory, or the platforms/android subdirectory. – Jason Clark Feb 3 '15 at 16:58
1

I had similar erros but am able to consistently get around this by having the following initial steps;

cd plugins/com.salesforce/src/android/libs/SalesforceSDK ant debug cd ../SmartStore ant debug cd ../SmartSync ant debug

Once I have run these the javac errors you mentioned above are no longer seen.

  • Sounds like a similar dance to the one I described in my answer; at least it sounds like it's an SDK issue and not a PEBKAC issue. Do your individual builds succeed? Mine fail, but allow the overall build to work. – Jason Clark Mar 18 '15 at 13:16
  • The individual ones work. I initially thought it was to do with my setup. I'm using nvm for my node so thought this could be the issue, but I only seem to have the problem on projects that have the Salesforce plugins. – Todd Halfpenny Mar 18 '15 at 13:29
0

I have gotten the basic app to run, although the steps seem counter-intuitive. I have tested this process several times, each time starting fresh with a new project via forcedroid create; I have not changed the generated files, except to paste in my working www/bootconfig.json.

Here are the steps that work for me:

  1. Create app: forcedroid create --apptype='hybrid_remote' --appname='testdroid' --companyid='com.example.testdroid' --organization='Stonehenge' --startpage='/apex/mobile_home' --targetdir='/Users/jclark/dev' --packagename='com.example.testdroid'

  2. Update www/bootconfig.json with correct consumer key/callback uri/start page

  3. cd testdroid/platforms/android
  4. ant debug - this will fail.
  5. cordova emulate android

Some notes on this process:

  • I'm skipping the tutorial's direction to run android update project. I didn't catch this yesterday, but this step throws errors regarding Failed to find version-tag string; in my testing running or not running has no effect. It's possible this is part of my issue, but I haven't figured out the root cause or remediation. Planning to investigate further.
  • Running step 4 will fail. Running step 5 without running step 4 first will fail. Running 4 after 5 will fail. Once step 4 is run, step 5 always works.
  • Step 5 was informed by this page in the Mobile SDK Guide.

This doesn't feel like the correct process - a failing build (step 4) shouldn't be required for another build (step 5) to work. I'm guessing there's a subproject dependency that isn't getting picked up by step 5. Not accepting my own answer yet; hoping someone else knows why I'm seeing these issues.

0

Similar issues here. I did these:

  1. npm install forcedroid –g
  2. npm -g install cordova
  3. forcedroid create
  4. Build the project in Eclipse based on the instructions in the command line
  5. modify bootconfig to use the Consumer key for the remote app in my developer org set callback to same which is testsfdc:///mobilesdk/detect/oauth/done

The project builds fine in Eclipse (Luna). When I run the project, I only see a black screen with controls on the right side, but on the left side, it's blank and eventually displays "Android". I don't get the salesforce login window. Any insights?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.