×

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.

Installing Nokia X code samples plug-in on Android Studio

Nokia X code samples plug-in helps you to easily load and run Nokia X code samples onto the Android Studio project workspace.

Perform the following steps to install the Nokia X code samples plug-in:

  1. On Android Studio, from the File menu, click Settings or click the Settings icon as shown below.

    Figure 11. Settings icon

    Figure 11. Settings icon

    The Settings dialog appears. Select Plugins from the left pane.

    Figure 12. Settings dialog

    Figure 12. Settings dialog

  2. Click Browse repositories. The Browse Repositories dialog appears.

    Figure 13. Browse Repositories dialog

    Figure 13. Browse Repositories dialog

  3. Click Manage repositories. The Custom Plugin Repositories dialog appears.

    Figure 14. Custom Plugin Repositories dialog

    Figure 14. Custom Plugin Repositories dialog

  4. Click Add (or the plus symbol) to add a new custom plug-in repository from which you can download and install the Nokia X code samples plug-in. The Add Repository dialog appears.

  5. Specify the following plug-in download URL in the Repository URL field and click OK:

    http://tools.nokia.com/nokia-x/IntelliJ/updates/updatePlugins.xml
    Figure 15. Adding the plug-in download URL

    Figure 15. Adding the plug-in download URL

    The plug-in download URL you specified is added to the Custom Plugin Repositories dialog.

    Figure 16. Plug-in download URL added to the Custom Plugin Repositories dialog

    Figure 16. Plug-in download URL added to the Custom Plugin Repositories dialog

  6. Click OK to return to the Browse repositories dialog.

  7. From the Repository drop-down list, select the following plug-in download URL you added earlier as shown below.

    http://tools.nokia.com/nokia-x/IntelliJ/updates/updatePlugins.xml
    Figure 17. Selecting the plug-in download URL for installation

    Figure 17. Selecting the plug-in download URL for installation

    The Nokia X Code samples plug-in is loaded in the left pane and is available for download and install as shown below:

    Figure 18. Nokia X code samples plug-in available for installation

    Figure 18. Nokia X code samples plug-in available for installation

  8. Select Nokia_X_Code_Samples from the list and click the Download and Install icon to proceed with the installation.

    Figure 19. Installing Nokia X code samples plug-in

    Figure 19. Installing Nokia X code samples plug-in

    A prompt appears requesting whether you want to proceed with the installation.

    Figure 20. Proceeding with Nokia X code samples plug-in installation

    Figure 20. Proceeding with Nokia X code samples plug-in installation

  9. Click Yes to proceed with the download and installation of the Nokia X code samples plug-in.

  10. Once the plug-in download is complete, text Downloaded is added next to the Nokia_X_Code_Samples in the Browse repositories dialog as shown below.

    Figure 21. Nokia X code samples plug-in downloaded

    Figure 21. Nokia X code samples plug-in downloaded

  11. Click Close to return to the Settings dialog. Now you can see the Nokia X code samples plug-in added to the Settings dialog.

    Figure 22. Nokia X code samples plug-in added to the Settings dialog

    Figure 22. Nokia X code samples plug-in added to the Settings dialog

  12. In the Settings dialog, click OK to complete the installation.

    Once the plug-in installation is complete, you will be prompted to restart Android Studio to activate the plug-in.

  13. Click Restart to restart Android Studio and complete the plug-in installation.

    Figure 23. Restarting Android Studio

    Figure 23. Restarting Android Studio

Loading Nokia X code samples on Android Studio

After installing Nokia X code samples plug-in on Android Studio, you can load them onto the Android Studio project workspace by performing the following steps:

  1. In Android Studio, from the Nokia menu, select Code Samples or click the Code Samples icon as shown below.

    Figure 24. Code samples icon

    Figure 24. Code samples icon

    The Code Samples dialog is displayed.

    Figure 25. Code samples dialog

    Figure 25. Code samples dialog

  2. Select a sample from the Examples list (for example, NIAP - PepperFarmSimulator) and click Open to load the sample onto the Android Studio project workspace. The sample is loaded onto the Project view.

    Figure 26. Sample loaded onto the Android Studio project workspace

    Figure 26. Sample loaded onto the Android Studio project workspace

    Important: If you are loading one of the OneAPK samples, ensure that you have installed the following packages using Android Studio - SDK Manager and you sync your project with gradle files by clicking the Sync Project with Gradle files icon in Android Studio:

    • Extras
      • Android Support Repository
      • Google Repository

Troubleshooting tips

This topic provides solutions for common problems that you may encounter while using the SDK tools that are part of the Nokia X services SDK.

Gradle project sync fails on Android Studio

Problem: When you try to load a Nokia X code sample project on Android Studio you get an error message: "Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly."

Figure 27. Gradle project sync failed.

Figure 27. Gradle project sync failed.

Solution:

  1. From Android Studio, select File > Settings. The Settings dialog appears.
  2. In the Settings dialog, select Projects Settings > Gradle and add the following arguments under Gradle VM options (figure 28):

    -XX:MaxHeapSize=256m -Xmx256m
    Figure 28. Adding arguments to Gradle VM options.

    Figure 28. Adding arguments to Gradle VM options.

  3. Click OK to save the settings.
  4. Click the Sync project with Gradle files icon as shown below to perform a sync (figure 29).

    Figure 29. Sync project with Gradle files.

    Figure 29. Sync project with Gradle files.


Last updated 25 June 2014

Back to top

×