For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
Run a Cordova Project in Android Studio
Develop your Cordova app with MobileFirst for Android using Android Studio.
Before you begin
You must have a Cordova app project set up with Apache Cordova CLI (see Create a new Cordova app without the MobileFirst template).
Procedure
- If you have not already done so, from the command line run
cordova prepare
This creates the mfpclient.properties file in the assets folder. If this file does not exist, we cannot run your app.
- Open the project in Android Studio.
- From Android Studio select File->New->Import Project.
- Navigate to the build.gradle file in project name and click OK.
- In the project navigator pane the project looks like this:
Table 1. Android Studio navigation pane Android Studio navigation pane Description of selected files
AndroidManifest.xml
One of the functions of the AndroidManifest.xml file is list the start up code for the app.
MainActivity.java
The start up code for the app.
config.xml
Various configurations including:
- Calls hooks.
- Points to the default html page:
<content src="index.html" />
www
Contains the JavaScript, HTML, and CSS files loaded into the WebView.
index.html
The initial html page loaded by the WebView, defined in the config.xml file.
mfpclient.properties
The file containing information for connecting to the MobileFirst server. See
- Run your application to view it in the emulator.
The app is displayed in the emulator.
- From the Run menu choose Run Android.
- Choose a device from the Device Chooser dialog.
What to do next
You now have your Cordova project set up in Android Studio. You must register your app before we can start writing your code. See Register Cordova applications to MobileFirst Server.
Parent topic: Develop Cordova apps for Android