Getting Started with ArcGIS Runtime API for Android

Sep 13, 2022 | Programming

If you’re looking to harness the power of location-based data in your Android applications, the ArcGIS Runtime API for Android is a fantastic tool at your disposal. This guide will walk you through the process of setting up the samples provided in the latest version of the API, ensuring you’re ready to create amazing mapping applications in no time!

Overview of the ArcGIS Runtime API for Android

The main branch of the ArcGIS Runtime API for Android repository contains sample app modules for version 100.15.1, which includes a focus on minor updates and bug fixes. Not only can you find samples that are optimized for older versions through git tags, but the newer ArcGIS Maps SDK for Kotlin version 200 comes equipped with a modern API tailored for Kotlin development. With this foundation, you are well on your way to innovating on the Android platform.

Prerequisites

  • Ensure you have compileSdkVersion 31.
  • Download and install Android Studio.
  • Get an ArcGIS Developers API key from here.

Setting Up Your Developer Environment

Your journey begins by downloading the sample repository and setting it up in Android Studio. Here’s how to do it:

  1. Clone the repository following the instructions from our developer instructions wiki page.
  2. Import the project into Android Studio:
    1. Click **Open** on the Welcome screen, or **File > Open** if already inside a project.
    2. Navigate to either arcgis-runtime-samples-android/java or arcgis-runtime-samples-android/kotlin and select OK.

Accessing Esri Location Services

To use Esri’s location services (like basemaps, routing, and geocoding), authentication is necessary. You can authenticate using either an API Key or an ArcGIS identity:

  1. API Key: This key grants access to services. Generate or retrieve your API key from your ArcGIS Developers Dashboard and configure it in the gradle.properties file in your home directory like this:
    API_KEY = "YOUR_API_KEY"
  2. ArcGIS Identity: Use an account from ArcGIS Online or ArcGIS Enterprise that belongs to an organization.

Running a Sample

Now that you’ve set everything up, let’s run a sample:

  1. Select the app module from the **Edit Configurations** dropdown in Android Studio.
  2. Click the **Run** button on the toolbar.

Building from Gradle

Additionally, you can use the Gradle Wrapper to execute build tasks. Here’s how:

$ ./gradlew assembleDebug

And to run the app, install it using:

adb -d install path/to/sample.apk

Built APKs are saved to arcgis-runtime-samples-android/[module-name]/build/outputs/apk.

Using the Sample Viewer

For a straightforward way to view the samples, you can download the sample viewer app from the Play Store or ArcGIS Online. Follow these steps to run it locally on your device:

  1. Download and unzip the file to obtain ArcGIS_Runtime_Sample_Viewer_Android_10010.apk.
  2. Install the APK using
    adb -d install path/to/ArcGIS_Runtime_Sample_Viewer_Android_10010.apk

    .

Troubleshooting

If you encounter issues while running samples, don’t hesitate to use GeoNet for community-driven support. You can ask for advice, report bugs, or request new samples! If your problem persists, consider submitting a new issue on the GitHub repository.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Inspiring Contributions

Anyone can contribute to the repository – whether it’s through code, documentation, or reporting bugs. If you’re interested, check out the guidelines in the contributing documentation.

Licensing

All code in this repository is licensed under the Apache License, Version 2.0. Read more about it in the license file.

Final Thoughts

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Ready to Explore!

Now that you have the knowledge to start working with the ArcGIS Runtime API for Android, it’s time to dive in and explore the possibilities it offers. Happy coding!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox