Introduction
This tutorial will guide you through writing a native “Hello World” Android* app in Android Studio* through the IDE Integration feature of Intel® INDE 2015.
About Intel® INDE
Intel® Integrated Native Developer Experience (Intel® INDE) is a productivity suite of C++ and Java tools and libraries that speed up the development of mobile and PC applications through code reuse for performance sensitive native code and integrated workflow support. Intel INDE enables creation of Windows applications on Intel® Architecture and Android applications on ARM and Intel® Architecture. Developers have the freedom to use Intel INDE within the IDE they prefer, including Microsoft Visual Studio*, Google Android Studio*, and Eclipse*. Intel® INDE also provides developers access to advanced platform capabilities like media acceleration, context sensing, OpenCL™ 2.0, and threading libraries, with a selection of compilers, analyzers and debugging tools. Intel® INDE is available in three editions: Starter, Professional and Ultimate. For additional information, view the Intel INDE announcement blog in the Intel® Developer Zone.
About Android Studio* Integration in Intel® INDE 2015
Android Studio* IDE Integration in Intel® INDE sets up all the environment you need for developing Native Apps through Android Studio* which includes the installation of Android Studio*, Android* SDK, NDK and other development tools like ANT and ADT plug-ins. The pain of starting a new NDK project in Android Studio* is very much eased with a new template called “Blank Activity With NDK Support” provided by Intel® INDE.
Pre-requisites
- 64 bit version of JDK 7 or above.
- Uninstall any pre-existing versions of Android Studio*.
INDE 2015 Setup
Download Intel® INDE 2015 and start the installation. IDE Integration is available on all the editions of the product. Choose your preferred edition to install and then the screen to your choice of IDE Integration would open up. Select Android Studio* Development Environment and proceed through the rest of the installation.
Creating Your First Native Android* App with INDE 2015
There is some setup required in Android Studio*. Choose the API level that you choose for your SDK and target device. For this article, I have chosen API level 19 for SDK and Emulator.
Open Android Studio*.
Click Android SDK Manager and choose the following to install if they are not installed already.
- Tools/
- Android SDK Tools
- Android SDK Build-tools (latest available)
- Android 4.4.2 (API 19)/
- SDK Platform
- ARM EABI v7a System Image
- Intel x86 Atom System Image
- Google APIs (x86 System Image)
- Google APIs (ARM System Image)
- Extras/
- Android Support Repository
- Android Support Library
- Intel x86 Emulator Accelerator (HAXM Installer)
Once all the packages are installed, Click FILE -> New -> Project.
New Project Wizard opens up. Rename your Application to “HelloWorld”.
Click Next. And choose the target form factors that you want to run your app on.
Click Next and choose the Activity template “Blank Activity With NDK Support” from Intel® INDE.
Click Next and change the Activity Name and key in the path to where NDK is installed under IDEIntegration of INDE installation directory. Click Finish.
You would see the HelloWorld activity in the Project Explorer. Let us have some insider look into the project files.
App/src/main/res/layout/activity_hello_world.xml defines the UI layout of your app. You may use the Design view to edit the UI.
App/src/main/java/HelloWorld.java has the event handlers for the UI elements. This also makes a call to the native code under App/src/main/jni/
App/src/main/jni/NativeCode.cpp implements the function getStringFromNative and this is the place to add all your performance sensitive native code.
Another important file in Android Studio* is build.gradle under app/src which manages the build configuration for your project. Letz take a closer look at that.
Make sure you have the right API versions for CompileSdkVersion and targetSdkVersion. abiFiler under NDK determines the target which is set to x86 by default. You may change it to ARM targets too. Also, make sure you mention the right Android Support Library version which may not be the same as API version. Here it is set to 20.0.0 because it is the latest in this dev environment.
Now build your App by clicking Build -> Rebuild Project. Gradle system automatically builds the project once you save some changes.
Once the build is successful, run the app. Click Run -> Run App. Choose a device to launch emulator. Our choice is Intel_Nexus_7_x86 that comes by default with IDE Integration. Click OK.
Since you have Intel® HAXM installed, the emulator should come up within a couple of minutes. When the emulator launches, you should see your first app in action.
Congratulations on your first milestone!
Troubleshooting tips
To speed up your emulator, install Intel® HAXM. Note that you need to turn ON Intel® VT in your BIOS and uninstall Hyper-V if it is installed on your machine.
Make sure JAVA_HOME is set to the latest 64-bit JDK that you have installed.
More troubleshooting tips can be added if you try this article and comment on it.
For additional support, visit INDE Support page.