Press ESC to close

Fixing Salesforce Mobile SDK (Android + Gradle) Issue

We recently got a new Salesforce hybrid mobile app project, based on previous experience with hybrid apps and Salesforce mobile SDK, we started out of excitement, which faded out pretty soon. This issue is only related to Android app release and recent versions of Cordova (seems v5.x onwards)

Here are steps to run into this issue:



– Get latest version of NPM, ForceDroid(Salesforce Mobile SDK 4.1.1 in our case), Cordova (v6.x in our case) and other required software installed.
–  $ forcedroid create to generate an app. I was trying “hybrid_local
– after app is generated try, $ cordova clean, $ cordova build, and $ cordova run android

This sample app, starts OAuth on login, and shows a list of users on completion. But on Android it directly loads a blank User list page i.e. no OAuth screen shown. Following video shows the issue and some resolution tips in details.



To reproduce the issue:

  • Its coming because few Salesforce plugins failed to build correctly, and thus crashes at runtime during load for “java.lang.ClassNotFoundException: com.salesforce.androidsdk.phonegap.plugin.SalesforceOAuthPlugin”

  • This error is only coming in Android platform, you can build and run the same app code easily on iOS without any change.

Ways to fix:

  • If you are having a Mac, most of the Cordova plugins are similar for getting started with Hybrid apps. You can try building and testing first on iOS and hope Salesforce will release fix for this issue soon, though it  was posted in Dec last year, but seems to be closed without a fix.

  • If you have an old working Hybrid app project from other apps or previous clients, try cloning that and downgrade to previous versions of Cordova i.e.

    • npm uninstall cordova

    • sudo npm install cordova@3.6.3-0.2.13

    • use “-g” switch in both commands, if you are willing to do it globally in your system.

Thanks:

– To Vikram Middha for help in nailing down the problem, and all the required pointers

Leave a Reply

%d bloggers like this: