Converting a MobileFirst Cordova project to an Android Studio-based project

Follow these instructions if you want to work with a MobileFirst Cordova project in Android Studio, and use Gradle building capabilities.

About this task

This procedure enables you to make changes to your Cordova project, build and deploy to MobileFirst Server, go to Android Studio, and build and deploy your app to an emulator or a device.


  1. Import the build.gradle file from your project to Android Studio:
    1. In Android Studio, click Import project (Eclipse ADT, Gradle, etc.).
    2. Go to your MobileFirst project under apps > android > native, and click build.gradle.
      Note: Make sure to click build.gradle and not the native folder.
    3. Click OK and accept any Gradle configuration that Android Studio prompts for.
  2. Accept Gradle Sync configuration.
  3. Optional: Fix any Gradle sync error by modifying the build.gradle file:
    1. From the Project tab, expand the Gradle Scripts drop-down menu, and open the file build.gradle (Module: android).
    2. Configure build.gradle to fix any gradle sync errror.

      The most common issues that you must resolve are dependencies issues. To know how to fix those problems, see the Gradle documentation: and

      Note: You must resolve all Gradle sync errors before continuing with this procedure.
  4. Run your application in Android Studio. If the application is deployed successfully, continue with this procedure. If you have other build errors, you might have to edit the build.gradle file again to adapt it to your project.
  5. Make a change to any file in the www folder and save it.
  6. In the MobileFirst Platform Command Line Interface, run the mfp cordova prepare command.
  7. Optional: If you need to deploy to MobileFirst Server, run the mfp push command.
  8. In Android Studio, from the Android drop-down menu, go to assets > www, open the file that you modified in step 5, and make sure the changes are present.
    Note: If your changes are not there, refresh your project in Android Studio
  9. Run the application.


The application is now deployed successfully in Android Studio.
Important: (Android and iOS development only.) When you add the Android or iOS platforms to your app that contains the cordova-plugin-mfp, an existing file in your app is replaced by a version of the file that is provided by MobileFirst Platform Foundation. These files are:
  • Android: The file is replaced. Your original file is backed up and renamed MainActivity.original.
  • iOS: File main.m is replaced. Your original main.m file is backed up and renamed main.m.bak.
If you made any changes to the original versions of these files, you must merge the changes that you made into the new version of the file that is provided by IBM MobileFirst™ Platform Foundation.