Skip to content

Initial Setup

Adding MapLayr to Your Project

Create GitHub token

GitHub package registry requires authentication credentials. These must be created by following the guide provided by GitHub.

You will need to enable the following scope on the GitHub token creation form:

read:packages

MapLayr plugin

Add GitHub package registry to project Gradle

If your project uses the legacy buildscript { dependencies } method to add build script dependencies then add the Github package registry to the top level build.gradle file as so:

build.gradle
buildscript {
    repositories {
        maven {
            url = "https://maven.pkg.github.com/attractions-io/maplayr-android"
            credentials {
                username "GitHub username here"
                password "GitHub token with packages read access here"
            }
        }
    }
}
build.gradle.kts
buildscript {
    repositories {
        maven {
            url = uri("https://maven.pkg.github.com/attractions-io/maplayr-android")
            credentials {
                username = "GitHub username here"
                password = "GitHub token with packages read access here"
            }
        }
    }
}

An example can be found here: build.gradle

If your project uses the pluginManagement { repositories } method to configure plugin resolution then add the Github package registry to the settings.gradle file as so:

settings.gradle
pluginManagement {
    repositories {
        maven {
            url = "https://maven.pkg.github.com/attractions-io/maplayr-android"
            credentials {
                username "GitHub username here"
                password "GitHub token with packages read access here"
            }
        }
    }
}
settings.gradle.kts
pluginManagement {
    repositories {
        maven {
            url = uri("https://maven.pkg.github.com/attractions-io/maplayr-android")
            credentials {
                username = "GitHub username here"
                password = "GitHub token with packages read access here"
            }
        }
    }
}
Use environment variables for credential storage To avoid saving your GitHub credentials directly in your repo you can add them to your environment variables. They can then be accessed like so: === "Groovy"
build.gradle
buildscript {
    repositories {
        maven {
            url = "https://maven.pkg.github.com/attractions-io/maplayr-android"
            credentials {
                username System.getenv("GITHUB_USERNAME")
                password System.getenv("GITHUB_TOKEN")
            }
        }
    }
}
=== "Kotlin"
settings.gradle.kts
buildscript {
    repositories {
        maven {
            url = uri("https://maven.pkg.github.com/attractions-io/maplayr-android")
            credentials {
                username = System.getenv("GITHUB_USERNAME")
                password = System.getenv("GITHUB_TOKEN")
            }
        }
    }
}

Add the MapLayr plugin class path to Gradle

Add the MapLayr plugin class path to Gradle by adding the following dependency to the top level build.gradle as so:

build.gradle
buildscript {
    dependencies {
        classpath 'io.attractions:maplayr-plugin:0.0.98'
    }
}
build.gradle.kts
plugins {
    id("io.attractions.maplayr-plugin") version("0.0.98")
}

An example can be found here: build.gradle

Add MapLayr plugin to Gradle

Add the MapLayr plugin to Gradle in the app module build.gradle as so:

app/build.gradle
plugins {
    id 'io.attractions.maplayr-plugin'
}
app/build.gradle.kts
plugins {
    id("io.attractions.maplayr-plugin") version("0.0.98")
}

An example can be found here: app/build.gradle

Legacy Gradle syntax
apply plugin: 'io.attractions.maplayr-plugin'

MapLayr

Add GitHub package registry to module Gradle

If your project uses the legacy per-module repositories {} block within the module's build.gradle file then add the GitHub package registry to the module level build.gradle as so:

app/build.gradle
repositories {
    maven {
        url = "https://maven.pkg.github.com/attractions-io/maplayr-android"
        credentials {
            username "GitHub username here"
            password "GitHub token with packages read access here"
        }
    }
}
app/build.gradle.kts
repositories {
    maven {
        url = uri("https://maven.pkg.github.com/attractions-io/maplayr-android")
        credentials {
            username "GitHub username here"
            password "GitHub token with packages read access here"
        }
    }
}

An example can be found here: app/build.gradle

If your project uses the centralised repository approach within settings.gradle using the dependencyResolutionManagement { repositories } block then add the GitHub package registry as so:

settings.gradle
dependencyResolutionManagement {
    repositories {
        maven {
            url = "https://maven.pkg.github.com/attractions-io/maplayr-android"
            credentials {
                username "GitHub username here"
                password "GitHub token with packages read access here"
            }
        }
    }
}
settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        maven {
            url = uri("https://maven.pkg.github.com/attractions-io/maplayr-android")
            credentials {
                username "GitHub username here"
                password "GitHub token with packages read access here"
            }
        }
    }
}

Add MapLayr implementation to Gradle module dependencies

app/build.gradle
dependencies {
    implementation "io.attractions:maplayr:0.0.98"
}
app/build.gradle.kts
dependencies {
    implementation("io.attractions:maplayr:0.0.98")
}

An example can be found here: app/build.gradle

Adding Your API Key

In the app module build.gradle configure the MapLayr plugin. The apiKey is required for any usage of the SDK

app/build.gradle
attractionsIo {
    apiKey = "{api_key}"
}
app/build.gradle.kts
attractionsIo {
    apiKey = "{api_key}"
}

An example can be found here: app/build.gradle