Intel® Developer Zone offers tools and how-to information for cross-platform app development, platform and technology information, code samples, and peer expertise to help developers innovate and succeed. Join our communities for Android, Internet of Things, Intel® RealSense™ Technology, and Windows to download tools, access dev kits, share ideas with like-minded developers, and participate in hackathon’s, contests, roadshows, and local events.
Introduction
This tutorial will guide you through writing a native "Hello World" Android* app in Visual 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 Visual Studio* Integration in Intel® INDE 2015
Intel® INDE 2015 has integrated the vs-android plug-in that is available for Visual Studio* with a special template called "Android X86 Native Project" in Visual C++. INDE 2015 also comes with Debugger Extension for vs-android to help debug the apps. Let us see how to build and deploy a sample native app through this feature.
Pre-requisites
Microsoft Visual Studio* 2012 or 2013 (Professional or Ultimate Editions). Express Editions are not supported.
32 bit version of JDK 7 or above
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 Microsoft Visual Studio* development environment and proceed through the rest of the installation.
This will download and install all the necessary tools including Android* SDK, NDK, ANT, ADT plug-ins, vs-android etc.
Creating Your First Native Android* App with INDE 2015
Open Visual Studio* and click FILE -> New -> Project.
New Project Wizard opens up. Under Installed -> Visual C++ -> Store Apps -> Android, you will see the "Android X86 Native Project" template. Rename your project to "Hello World"
Intel X86 Native Development Experience Android* Project Wizard opens up which allows you to choose your Project Settings. Choose the same API settings that is set in the emulator or your target device.
Choose the defaults in the next page "Activity Settings" and finish.
Now you will see the solution file built in Visual Studio*.
Right Click on the "Hello World1" solution file and click Properties. The important ones are already highlighted. Choose the right API level and it should match with the emulator you are going to run. You have an option to choose an ARM target from the Target Architecture. X86 Architecture is selected by default. Platform Toolset is selected as x86-4.6 which points to GCC. You can also choose ICC.
Let us quickly review some important files here on the Solution Explorer.
Jni/NativeCode.cpp has the native C++ code which can access all the native libraries and headers.
Open res/layout/activity_main.xml from the Solution Explorer. This file defines the UI lay out of your app. Note that there is no designer view for this yet.
Open src/MainActivity.java from the Solution Explorer. This file defines the event handlers for your app and calls the native method from here. For instance, the method "getStringFromNative()
" is the interface call to the function defined in jni/NativeCode.cpp.
Before you build and deploy this sample, you must start the emulator. For this, go to <inde_install_directory>\INDE\IDEintegration\SDK and start AVD Manager.exe. Start Intel_Nexus_7_x86 emulator that comes by default with this IDE Integration. Make sure that the API level is the same as what you chose in the Project Wizard in Visual Studio*.
Now to build and deploy, choose BUILD -> Build Solution from Visual Studio*. After the build is successful, choose BUILD -> Deploy Solution. You should see HelloWorld app installed in the emulator.
Click "HelloWorld" app and you should see your first app at work.
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 32-bit JDK that you have installed.
- You may see this – "Error occurred during initialization of VM, Could not reserve enough space for object heap, Could not create the Java virtual machine". The fix will be to increase the MAX heap size by adding –Xmx512M (it could be any big number) to the environment variable _JAVA_OPTIONS
More troubleshooting tips can be added if you try and comment on this article.
For additional support, visit INDE Support page.