Salesforce Mobile SDK 4.0.0 Bug – Removing and Adding the Android Platform

During our adoption and testing of the latest version of the Salesforce Mobile SDK (v4.0.0) we noticed a bug with the behaviour when using it via the Cordova plugin for Android.

We found that if you set up the project as follows (and as per the README, but specifying the cordova-android version to 5.0.0) then all was fine.

However if for some reason you were to remove and re-add the Android platform via the following standard commands then you’re build would fail.

The following output is seen following the platform add command

And errors like this can be seen in the Messages panel when building via Android Studio

We spotted that the tools/postinstal-android.js script that is run after the platform is added moves some files relating to gradle across to the platforms directory. This is fine for the first addition of the Android platform but subsequent runs of this cannot find the source files as they were moved out of the source directory.

Pull Request 139 was created and submitted to the project and has since been merged into the master branch. The changes were to simply make the process copy the files, rather than move them.

This Salesforce Mobile SDK 4.0.0 Bug should now be fixed if installing the master branch.