SDK tools

Nokia X services SDK includes a set of tools that you can use to enhance your productivity while developing apps for the Nokia X software platform. The tools list include Nokia X services, Nokia X Eclipse extensions (that includes a code analyser and plenty of code samples), Nokia X emulator and so on. This section guides how to use these tools and quickly develop new apps or port existing apps to the Nokia X software platform.

This section also describes how to change the IMEI and MNC/MCC values of the Nokia X emulator. In addition, it also guides how to use Nokia X services SDK on Android Studio for app development.

Nokia X Eclipse extensions

Nokia X services include the following optional Nokia X Eclipse extensions:

  • Nokia X Analyser offline plug-in: This Eclipse extension installs the Nokia X Analyser offline tool. You can use this tool to analyze and check whether alternate Nokia-specific service APIs are available for use instead of default Google service APIs. For more information, see Nokia X Analyser user guide.
  • Nokia X Code Samples plug-in: This Eclipse extension installs the Nokia X Code Samples plug-in. Once this plug-in is installed, you can load Nokia X Code Samples directly to your Eclipse workspace using the Nokia menu option. For more information, see Using the Nokia X Code Samples plug-in for Eclipse.

Installing Nokia X Eclipse extensions

You can install the Nokia X Eclipse extensions by performing the following steps:

Important: Nokia X Analyser (offline) is supported on 32-bit and 64-bit versions of Eclipse with the respective Java Development Kit (JDK) version installed. You can ignore these steps, if you have already installed Nokia X Eclipse extensions using the Nokia X services SDK installer.

  1. In Eclipse, from the Help menu, select Install New Software. The Install dialog appears.

    Figure 1. Install dialog

    Figure 1. Install dialog

  2. Click Add. The Add Repository dialog appears.

  3. In the Add Repository dialog, configure the following details and click OK.

    • Name: Specify a name of your choice for the repository. For example, Nokia X Eclipse extensions.
    • Location: Click Local and select the Nokia X Eclipse extensions installable path as: <android-sdk-path>\extras\nokia\nokia_x_services\tools\nokia-x-eclipse-extensions.
    Figure 2. Add Repository dialog

    Figure 2. Add Repository dialog

    Nokia X Eclipse extensions are now available for installation.

  4. Select the Nokia X Eclipse extensions that you want to install and click Next.

    • Nokia X Analyser
    • Nokia X Code Samples
    Figure 3. Selecting Nokia X Eclipse extensions to be installed

    Figure 3. Selecting Nokia X Eclipse extensions to be installed

    Follow the on-screen installation instructions to complete the installation. Also, ensure that you accept the license agreement when prompted.

  5. Once the installation is complete, you will be prompted to restart ADT. Click Yes to restart.

    Figure 4. Restarting ADT

    Figure 4. Restarting ADT

    Nokia X Eclipse extensions are now installed on Eclipse.

Using the Nokia X code samples plug-in for Eclipse

Nokia X services includes an optional Nokia X Eclipse Extension, the Nokia X code samples plug-in. After installing this plug-in, you can load Nokia X code samples directly to your Eclipse workspace using the Nokia menu option. For more information about installing the extensions, see Installing Nokia X Eclipse extensions.

Nokia X code samples demonstrate the working of Nokia-specific service APIs (Nokia Notifications, HERE Maps, and Nokia In-App Payment).

To load and run a Nokia X code sample from your Eclipse workspace, perform the following steps:

  1. In Eclipse, from the Nokia menu, select Code Samples.

    Figure 1. Selecting code samples

    Figure 1. Selecting code samples

    This displays the Nokia X code sample list.

  2. Select the code sample that you want to load from the list and click Load into Workspace.

    Figure 2. Loading a code sample into the Eclipse workspace

    Figure 2. Loading a code sample into the Eclipse workspace

    The selected code sample appears in the Package Explorer view as shown below.

    Figure 3. Code sample loaded in the Package Explorer view

    Figure 3. Code sample loaded in the Package Explorer view

  3. If you have selected HERE - BasicHereMapSolution, HERE - ExtendedBasicMapSolution, or HERE - SimpleRoutingSolution, ensure that you perform the following additional steps:

    1. Right-click on the project and select Properties > Java Build Path > Libraries tab.

    2. Click Add External JARs and select <Android SDK path>\extras\nokia\nokia_x_services\libs\here\com.here.android.sdk.jar and click OK.

    3. Make sure that the library is not exported to JAR, i.e. the check box is not checked in Order and Export tab.

    Figure 4. Selecting the HERE libraries

    Figure 4. Selecting the HERE libraries

  4. If you have selected HERE - MapsV1OneApk or HERE - MapsV2OneApk, ensure that you perform the additional steps described in One APK with HERE Maps and Google Maps.

  5. Right-click on your project and select Run As > Android Application to run the sample app. The output appears for the BasicHereMapSolution sample as shown below:

    Figure 5. Running the sample app

    Figure 5. Running the sample app

Uninstalling Nokia X code samples plug-in

  1. In Eclipse, from the Help menu, select About ADT. The About ADT dialog appears.

    Figure 6. About ADT dialog

    Figure 6. About ADT dialog

  2. Click Installation Details. The ADT Installation Details dialog appears listing the details of software installed.

    Figure 7. ADT Installation Details dialog

    Figure 7. ADT Installation Details dialog

  3. Select Nokia X Code Samples and click Uninstall. The Uninstall dialog appears.

    Figure 8. Uninstall dialog

    Figure 8. Uninstall dialog

  4. In the Uninstall dialog, click Finish to complete the uninstallation.

  5. Once the uninstallation is complete, you will be prompted to restart ADT. Click Yes to restart.

    Figure 9. Restarting ADT

    Figure 9. Restarting ADT

Changing the IMEI and MCC/MNC number of Nokia X emulator

The getDeviceId() method of the TelephonyManager class returns the IMEI number of the Nokia X emulator. The default IMEI number returned is 000000000000000.

The getNetworkOperator() method of the TelephonyManager class returns the mobile country code (MCC) / mobile network code (MNC) value of the Nokia X emulator. The default MCC/MNC value returned is 24405. This is the equivalent of 244 (MCC - Finland) and 05 (elisa - MNC).

In addition, you can also use the following methods of the TelephonyManager class for your app:

  • getSubscriberId() - Provides the concatenation of MCC and MNC followed by zeros till the entire length of IMSI becomes 15. For example, if you have set MCC as Finland (244) and MNC as Elisa (05) using the Nokia X Settings app, then getSubscriberId() returns 244050000000000.
  • getNetworkOperatorName() - Returns the MNC operator name in the same way it is listed in Settings.
  • getSimOperator() - Returns the MCC+MNC of the provider of the SIM.
  • getSimOperatorName() - Returns the service provider name in the same way it gets listed in Nokia X Settings.
  • getNetworkCountryIso() - Returns the MCC country ISO Codes. For example, for Finland it returns FI and for INDIA it returns IN.

Steps

You can change the default IMEI and MCC/MNC values returned by performing the following steps:

Important:

  • The IMEI number change applies only to the API calls of the get Id() method, and does not change the actual IMEI number of the Nokia X emulator (Settings > About phone > Status > IMEI).

  • Ensure that the following uses-permission is added to your app’s AndroidManifest.xml file for the following steps to work on your app:

    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  1. Launch the Nokia X emulator.

  2. Once the Nokia X emulator has successfully launched, swipe down and launch the Nokia X settings app.

    Figure 1. Launching the Nokia X Settings application

    Figure 1. Launching the Nokia X Settings application

    The default IMEI and MCC/MNC values are displayed.

    Figure 2. Default IMEI and MCC/MNC values

    Figure 2. Default IMEI and MCC/MNC values

  3. Configure the following values and click Apply.

    • IMEI - Enter a 15-digit IMEI number. For example, 456378629982098.
    • MCC - Select the mobile country code value that you want to use. For example, Germany (262).
    • MNC - Select the mobile network code value that you want to use. For example, Vodafone.de (02).

      Figure 2. Configuring IMEI and MCC/MNC values

      Figure 2. Configuring IMEI and MCC/MNC values

      The new IMEI and MCC/MNC values are set for the Nokia X emulator.

      Figure 3. Updated IMEI and MCC/MNC values

      Figure 3. Updated IMEI and MCC/MNC values

  4. You can verify that the IMEI number has changed by entering *#06# after launching the Phone app from the Nokia X emulator.

    Figure 4. Changed IMEI number

    Figure 4. Changed IMEI number

    The updated IMEI number is displayed.

  5. You can verify that the MCC/MNC number of Nokia X emulator has changed by using the getNetworkOperator() method of the TelephonyManager class in your app.

Important: Please note that the changed IMEI and MCC/MNC values are reset to their default values after you restart the Nokia X emulator, unless “Snapshot” is selected in AVD emulation options.

Why should I change the MCC/MNC values of Nokia X emulator?

Changing the default MCC/MNC values of Nokia X emulator helps you to test your app and check how they behave in different countries and network operators with respect to pricing.

Important: If your app is already running, before changing the default IMEI and MCC/MNC values of Nokia X emulator, ensure that you restart the app to reflect the changes. To update IMEI on Nokia In-App Payment enabler, it must be restarted: Settings -> Apps -> Manage apps -> All -> Nokia In-App Payment -> Force stop + Turn off and then turn back on.

Here is an example how the output of the Pepper Farm Simulator sample app (located in <Android SDK installation path>/extras/nokia/nokia_x_services/samples/niap/PepperFarmSimulator) differs. With MCC set as Finland (244) and MNC set as elisa (05) the output of the sample app is as follows:

Figure 5. Pepper Farm sample app output - Home page

Figure 5. Pepper Farm sample app output - Home page

Here, the network operator shows Elisa with its respective icon and currency values are in euros.

Figure 6. Pepper Farm sample app output - Checkout page

Figure 6. Pepper Farm sample app output - Checkout page

With MCC set as India (404) and MNC set as Vodafone IN (01) the output of the Pepper Farm Simulator sample app is as follows:

Figure 7. Updated IMEI and MCC/MNC values

Figure 7. Updated IMEI and MCC/MNC values

Figure 8. Pepper Farm sample app output - Home page

Figure 8. Pepper Farm sample app output - Home page

Here, the network operator shows Vodafone in with its respective icon and currency values are in Indian rupees.

Figure 9. Pepper Farm sample app output - Checkout page

Figure 9. Pepper Farm sample app output - Checkout page

Android Studio user guide

In addition to the Android Developer Tools (ADT) plug-in for Eclipse / Android SDK, you can also use Android Studio (a new Android development environment based on IntelliJ IDEA) for developing and porting apps using Nokia X services SDK.

Installing and configuring Android Studio

Download and install the latest version of Android Studio from the Android Studio web page. Note that Android Studio requires the latest version of Java Development Kit (JDK) to function (JRE alone is not sufficient). Make sure that the bit version of the bundle matches the JDK, that is, both need to be either 32-bit or 64-bit.

Note: Nokia X services SDK is tested on Android Studio v0.4.6 (early access preview).

Installing the required tools and packages

  1. Open Android Studio. The Android Studio welcome page appears.

    Figure 1. Android Studio welcome page

    Figure 1. Android Studio welcome page

  2. In the Android Studio welcome page, create a new project or open an existing project using the default settings. This launches the Project view for your project in Android Studio.

    Note: The welcome page does not always appear. In that case, click the File menu to create or open a project.

  3. From the Tools menu, select Android > SDK Manager. The Android SDK Manager dialog appears.

  4. From the Android SDK Manager, ensure that the following Android SDK and tools are installed:

    • For Nokia X2 install the packages for Android 4.3 API 18:
      • Android API version 4.3 API 18
        • SDK Platform
        • ARM EABI v7a System Image (emulator prerequisite for ARM system images)
        • Intel x86 Atom System Image (emulator prerequisite for x86 system images)
    • For Nokia X/X+/XL install the packages for Android 4.1.2 API 16:
      • Android API version 4.1.2 API 16
        • SDK Platform
        • ARM EABI v7a System Image (emulator prerequisite for ARM system images)
        • Intel x86 Atom System Image (emulator prerequisite for x86 system images)
    • Tools
      • Android SDK Tools
      • Android SDK Platform-tools
      • Android SDK Build-tools 18.1.1
    • Extras
      • Intel x86 Emulator Accelerator (emulator prerequisite for x86 system images)
  5. Close Android SDK Manager and Android Studio to install the Nokia X services SDK.

  6. See the Install Nokia X specific packages section on Environment setup page for instructions on how to install the SDK add-ons.

    To check whether the installation was successful, open the Android SDK Manager as shown below and ensure that the following packages are installed:

    Figure 2. Launching Android SDK Manager

    Figure 2. Launching Android SDK Manager

    • For Nokia X2:
      • Android 4.3 (API 18)
        • Nokia X software platform 2.0
    • For Nokia X/X+/XL:
      • Android 4.1.2 (API 16)
        • Nokia X software platform 1.1
    • Extras
      • Nokia X Device Definitions
      • Nokia X services
      • Nokia X USB Driver
    Figure 3. Nokia X specific packages are now installed

    Figure 3. Nokia X specific packages are now installed

Configuring Android Studio to build using Nokia X services SDK

  1. Open Android Studio.

  2. Select Configure > Project Defaults > Project Structure.

    -OR-

    If your project is already open, from the File menu, select Project Structure. For default project settings, select File > Other Settings > Default Project Structure. The Project Structure dialog appears.

    Figure 4. Project Structure dialog

    Figure 4. Project Structure dialog

  3. Under Platform Settings, select SDKs and click Add New SDK (+ symbol) > Android SDK.

    Figure 5. Adding new SDK

    Figure 5. Adding new SDK

    The Select Home Directory for Android SDK dialog appears.

    Figure 6. Selecting Home Directory for Android SDK

    Figure 6. Selecting Home Directory for Android SDK

  4. Select the path in which Nokia X services SDK is installed as shown above and click OK. The default path is <androidstudio-install-path>\sdk. The Create New Android SDK dialog appears.

  5. Under Build Target, for Nokia X2, select Nokia X software platform 2.0 (4.3) and for Nokia X/X+/XL, select Nokia X software platform 1.1 (4.1.2). Once you are done click OK.

    Figure 7. Selecting build target as Nokia X software platform 2.0

    Figure 7. Selecting build target as Nokia X software platform 2.0

    Figure 8. Selecting build target as Nokia X software platform 1.1

    Figure 8. Selecting build target as Nokia X software platform 1.1

    The selected build target is added to the SDKs list. Now your projects are ready to build using Nokia X software platform.

    Figure 9. Nokia X software platform 1.1 added

    Figure 9. Nokia X software platform 1.1 added

    Figure 10. Nokia X software platform 2.0 added

    Figure 10. Nokia X software platform 2.0 added

  6. Click OK to complete the configuration.