Installing MapLibre GS Native on Android

Posted by rtnf on 7 January 2023 in English. Last updated on 16 January 2023.

Back then, my laptop was a potato, so i can’t afford to run Android Studio decently. That’s why i never touched Android Development at all back then.

But now, I got core i5 + SSD. Let’s try Android Development once again, all from scratch.

Download and install :

  • Download android-studio-2021.3.1.17-windows.exe (912.92 MB)
  • Install. But it downloads several additional packages. Wait, then finished.
  • Open. Create new project. But it downloads, yet again, several additional packages. Wait, then it finally finished. In the end, my Android Studio downloaded additional 2.1 GB data.

Now, for starter, let’s make a map app by using MapLibre GL Native.

Why MapLibre? I stumbled across “Overpass Ultra” , a fork of OverpassTurbo that claimed better performance than OverpassTurbo since it used “MapLibre GL” (GPU-accelerated vector rendering library) instead of Leaflet (which is used by Overpass Turbo). I simply want to test their claim.

Okay, let’s read the installation guide on MapLibre’s github page.

First, let’s add Maven Central repository. It’s a “central server” that stores libraries, packages, and everything else. Just like Python’s “pip” or Linux’s “apt” or Node’s “npm”, it’s a convenient public service to make developer life’s way much better.

Open “Gradle Scripts -> build.gradle (Project : )”. Here’s what I got after opening that file :

plugins {
    id '' version '7.3.1' apply false
    id '' version '7.3.1' apply false
    id '' version '1.7.20' apply false

Now, let’s modify it like this :

plugins {
    id '' version '7.3.1' apply false
    id '' version '7.3.1' apply false
    id '' version '1.7.20' apply false
allprojects {
    repositories {

While MapGL Native is located at mavenCentral, I added additional gradlePluginPortal (for Gradle-related dependencies) and google (for any official google dependencies).

Then, let’s sync. But unfortunately, it failed. “Build was configured to prefer settings repositories over project repositories”. Oh no.

Let’s copy-and-paste this error message right to Google Search. Suddenly, it solved! Many thanks to YCuiCui’s answer on StackOverflow. All I had to do is just open the settings.gradle, and delete the whole dependencyResolutionManagement block.

Alright, by the way, what is a “Gradle” anyway?

Put it simply, it’s a build tool. Back then, compiling an app solely by using command-line hackery was really tedious and hard. Something something like javac -> java ClassName. The complexities are increased exponentially if our apps consisted of tons of source code files. By using build tool, everything can be easier, in the automated way.

Hans Dockter created Gradle in 2008. Then in 2013, Google selected Gradle as default build tool for Android. Here’s an excerpt of his interview regarding the history of gradle :

As I started using Groovy as a technology for my initial build system, I thought it would be good idea to attend the first ever Groovy and Grails Exchange. There I met Steven Devijer, the co-founder of Grails, who was also doing some work on an internal build tool for his client. We both got very excited about pushing a new build system forward.

Gradle was, always has been, and always will be our idea for a more efficient continuous delivery tool.

Google’s involvement with the new Gradle-based Android build system was a dramatic accelerant for the community. We’ve made more progress in the last year than I anticipated we’d make in five.

We decided to use Groovy as the language of build.gradle files. But 90% of Gradle is written in Java.

Okay, let’s back to installing MapLibre. After we registered the repository’s location (mavenCentral, Gradle and Google), we should register the MapLibre library itself. Let’s open Gradle Scripts -> build.gradle (Module: ) , and add this line inside the dependencies bracket.

dependencies {
        implementation '<version>'

Umm. Well.. Version? What version? MapLibre’s official documentation on Github doesn’t say anything about which version is it. Aaa. Help.

At first, I guessed that it’s probably android-sdk version. I see the build.gradle (module) file, and there’re several sdk versions over there. Compile sdk (32), min sdk (21) and target sdk (32). I tried all of them, but i failed.

Then, I guessed once more. It’s probably maplibre’s version right? Now where i can see the latest maplibre’s version? I can’t see it on MapLibre’s github page. Now, let’s see in Maven Central website. Search “maplibre”. Got it! “” (latest version). So, it’s 9.6.0 afterall.

I put “9.6.0” on that placeholder, and finally it works. Sync success

To be continued on the next part


Login to leave a comment