This post is for ArcGIS Android SDK v10.1.1 and earlier. If you are using ArcGIS Android SDK v10.2 or above please refer to the more recent blog post here.
JetBrains IntelliJ IDEA Community Edition offers advanced support for development of Android applications. Currently the ArcGIS Runtime SDK for Android provides developer tooling exclusively for Eclipse but developers who use alternative Android developer environments can include the required libraries to enable development with the ArcGIS Runtime for Android. In this post I will walk you through the basics of setting up an IntelliJ IDEA project for ArcGIS Android development.
Extract ArcGIS Runtime SDK for Android libraries
Currently the ArcGIS Runtime SDK for Android download is wrapped as an Eclipse Plugin Update Site to easily integrate all the developer tooling we provide into your Eclipse Android Developer Tools (ADT) environment. You can extract the ArcGIS Android API required libraries from the ArcGIS Runtime SDK for Android using your platform zip and/or Java jar utility.
- Download the ArcGIS Runtime SDK for Android.
- Create a directory on disk to extract the download, e.g. ArcGISAndroidSDK_v2.
- Extract the contents of the ArcGIS SDK for Android download into the new directory using a Zip utility.
- Open a terminal or command prompt and change directory (cd) into the plugins directory where you extracted the SDK. E.g. /home/user/ArcGISAndroidSDK_v2/plugins.
- The API libraries are bundled in a jar file inside the plugins directory. You can use a Zip utility or the Java JDK Jar tool to extract the libraries from com.esri.arcgis.android.core_126.96.36.199206210956.jar file. I offer a jar command which extracts the contents of the lib and libs folders. These folders hold the jar files and native libraries for developing with the API.
- Two new directories are added to your plugins folder which hold the required jars and native libraries to work with ArcGIS Android API.
Now that you have the lib and libs folders extracted to disk we can use them in an IntelliJ IDEA Android module project.
Create New Android Module Project
IntelliJ IDEA supports Android development much in the same way the ADT extends Eclipse for Android development. It offers excellent code assistance, integrated logcat, layout preview, lint, etc. Refer to the IntelliJ IDEA Web Help system to enable Android support. Once you have Android support enabled you can create a simple Android application from scratch.
Add ArcGIS Android API native libraries
ArcGIS Android API uses native libraries for OpenGL ES 2.0 support. These native libraries are located in the libs folder you extracted from the ArcGIS Runtime SDK for Android download. The libs folder matches the libs folder created in all Android projects. Copy the contents of the extracted libs folder to you IntelliJ IDEA Android project libs folder.
Create an ArcGIS Android global library
Creating a global library will allow you to add ArcGIS module dependency to any valid Android project.
- Right click your Android Project and select Open Module Settings.
- Under Platform Settings select Global Libraries.
- Click the New Global Library button
- Select Java from the New Global Library drop down.
- Navigate to the location of the extracted lib folder from the Select Library Files dialog.
- Select the ArcGIS_Android.jar, jackson-core-lgpl-1.9.5.jar, and jackson-mapper-lpgl-1.9.5.jar files and click OK.
- With the Project Structure dialog still open, select Modules under Project Settings.
- You should see the ArcGIS_Android module listed, check the Export check box to ensure the jars are included with your project during deployment.
- Click OK to exit the Project Structure dialog.
Your Project Structure should resemble the following:
Update the Android Manifest
Open your Android Manifest file by double clicking on the AndroidManifest.xml file in your project directory. Add the following elements to your projects manifest under <uses -sdk> and above the <application> elements.
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Now you are ready to start programming with the ArcGIS Android API. If you are new to developing with the API follow the Hello World Map document ignoring all references to Eclipse tooling.
Once you have set up the ArcGIS_Android global library you can add it to any Android Module project. You will always have to copy the native libraries manually into your Android Module project directory. We provide supported tooling advantages for using the ArcGIS Runtime SDK for Android in Eclipse with the Android ADT, e.g. importing samples, automation of new projects, and fixing project properties to update your projects with the latest release, but this post offers an alternative development approach as more developer options become available for the Android developer community.