Tag Archives: forcedroid

Errors Creating Hybrid Apps in Mobile SDK 4.3

If you’re upgrading to Mobile SDK 4.3.x and plan to build hybrid apps, heed this tip!

Under certain conditions, the Cordova telemetry feature can cause forcedroid or forceios to fail with bewildering error messages. So far, we’ve seen this problem occur when:

  • You’ve installed the latest version of Cordova (6.2.0 or higher)
  • You’re using forcedroid or forceios to create a hybrid app

If both of the above are true, the script might throw an error such as the following:

“”. Should be in the format x[.y[.ignored]]

) is less than the minimum required version (5.4.0). Please update your version of Cordova.”

These errors occur if you haven’t preset telemetry to some value. Even if you don’t get weird error messages, you’ll still eventually get this prompt asking you to set the telemetry attribute:

May Cordova anonymously report usage statistics to improve the tool over time?

To avoid these hiccups, preset telemetry on or off before you run the script. Just type:

cordova telemetry <on|off>

Afterwards, forcedroid or forceios should work as expected.

For more information, type:

cordova telemetry -h

Creating Hybrid Android Apps with Mobile SDK 4.1.1

If you’re having problems creating hybrid apps with forcedroid–this blog post’s for you.

Lately, our developers have reported errors such as:

“The node package shelljs is required to use this script. Run ‘npm install shelljs@0.5.3‘ before running this script.”

Or:

“Error: Execution failed for task ‘:processDebugManifest’.
> Manifest merger failed with multiple errors, see logs”

Or:

“Failed to install ‘com.salesforce’:Uh oh! 

/Users/xxxxx/HybridApps/myApp/plugins/com.salesforce/src/android/assets/icudt46l.zip not found!”

Errors such as these frequently come from mismatched versions of external dependencies, or unforeseen updates to others. We’re working hard to fix these issues in the upcoming Mobile SDK release. In the meantime, though…Despair not! There’s an easy workaround.

To avoid these issues, we recommend you create and configure your hybrid Android apps entirely from the Cordova command line. You can call cordova create instead of forcedroid create, followed by any other Cordova commands you need. We’ve recommended this approach for a while as an alternative. Nowadays, though, it’s a necessity for these corner cases.

Be careful to observe two important details:

  1. Always add the SalesforceMobileSDK-CordovaPlugin last, after any other plugins.
  2. Specify the version of each platform you add. For Android, use:
cordova platform add android@5.0.0

For iOS:

cordova platform add ios@3.9.2

Note These values apply to Mobile SDK 4.1.1 and will likely change with later releases, so be vigilant!

After you’ve run cordova prepare, open your project in Android Studio and run it from there. Remember to open the project at <project_folder>/platforms/android/.

Here’s an example.

Create a Hybrid Android App with the Cordova Command Line

The following procedure creates a project named “contactsApp” in a target directory named “contactsApps”. This project incorporates the ContactExplorer hybrid sample app from the SalesforceMobileSDK-Shared git repo.

1. cd to a directory you use for storing Mobile SDK hybrid projects.

2.  Run the following commands.

cordova create contactsApp com.salesforce.contactexplorer contactsApp
cd contactsApp
cordova plugin add org.apache.cordova.contacts
cordova plugin add org.apache.cordova.statusbar
cordova plugin add https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin
cp -RL /SalesforceMobileSDK-Shared/samples/contactexplorer/* www/
cordova platform add android@5.0.0
cordova platform add ios@3.9.2
cordova prepare

3. From the Android Studio welcome screen, import the contactsApp/platforms/android folder. If, by any chance, you already have contactsApp installed on your device or emulator, we recommend Force Stopping it and then uninstalling the app before debugging your new app.

4. Run ‘android’.