Sitemap

Member-only story

How do we use a map without an Api key in Android Kotlin.

2 min readApr 6, 2025

--

Whenever we use Google Maps, we need an Api key. An API key from Google needs a billing account. After that we can use Google Maps in our project. So here I found an alternative to Google Maps. Today, we will learn map integration without using an API key with OpenStreetMap (OSM)

So let's get started, first of all, we need to add a dependency and view binding in the build.gradle.kts file.

buildFeatures {
viewBinding = true
}

implementation("org.osmdroid:osmdroid-android:6.1.16")

Now we need to add some permissions in AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Let's start with the design in activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<org.osmdroid.views.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />…

--

--

Harshita Bambure
Harshita Bambure

Written by Harshita Bambure

Android Developer || WomenTech Global Ambassador at WomenTech Network. || Yoga Teacher || Member @WTM .