Trying to migrate from google maps to tomtom for android. Having all kinds of problems. First documentation implies there are several APIs but in the dashboard I only have one option, traffic, which I don’t think I need but since it’s the only thing offered, I added that api key to my project. Then after adding suggested items to gradle, my project fails to build. All the errors are on the items added for tomtom. After commenting them out, gradle builds but obviously no tomtom maps. Specifically the items that caused errors were… the buildConfigField() line (in default config) which contains the API key among other things and the Implementation lines.
Hi
just to be sure that we are on the same page, have you followed Migrate from Google Maps to TomTom? Have you added the TomTom repository and sync your project?
The buildConfigField()
is a Gradle method and it is used only to provide the API key to the project.
buildConfigField("String", "ROUTING_API_KEY", "\"YOUR_API_KEY\"")
A small part of my problem was relieved, yesterday only Traffic APIs was available, today there are many. The other problems remain. When I put those lines in Gradle and Sync, everything appears fine, but anything I put in the app TomTom related is in Red TomTom not recognized. So, I comment all the TomTom stuff out and try to build app without it, and it fails due to the TomTom lines in Gradle. Including the line you referenced. Once I comment out all TomTom lines in Gradle, the project builds just fine, but obviously now there is nothing TomTom related that is still in there uncommented.
The only TomTom line in Gradle that does not cause an error on build is…
maven {
url “https://maven.tomtom.com:8443/nexus/content/repositories/releases/”
}
So, now the buildConfigField is working too, I have no idea the difference now from before in that regard. However, the implementation lines still throw errors… Failed To Resolve com.tomtom.online:sdk-maps:2.4782
Can you share your build.gradle
file? It will be easier to find a solution
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
mavenCentral()
maven {
url 'https://maven.tomtom.com:8443/nexus/content/repositories/releases/'
}
}
ext {
activityVersion = '1.4.0'
appCompatVersion = '1.4.0'
constraintLayoutVersion = '2.1.2'
coreTestingVersion = '2.1.0'
coroutines = '1.5.2'
lifecycleVersion = '2.4.0'
materialVersion = '1.4.0'
roomVersion = '2.4.0'
// testing
junitVersion = '4.13.2'
espressoVersion = '3.4.0'
androidxJunitVersion = '1.1.3'
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Try to move it to allprojects
in your project’s build.gradle
allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://maven.tomtom.com:8443/nexus/content/repositories/releases/"
}
}
}
Or if you are using the newer Android Studio place it in the settings.gradle
file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url 'https://maven.tomtom.com:8443/nexus/content/repositories/releases/'
}
}
}
Using allprojects didn’t work, plus my ide says that is deprecated and shouldn’t be used. I had tried that before. The suggestion to move the line to Settings seems to have totally worked. Thanks a lot.
I did this and it still didn’t work for that same situation, do you have any idea why?
Repo URL for legacy SDK has changed and it is now:
https://repositories.tomtom.com/artifactory/maps-sdk-legacy-android
I encourage to use current SDK: Introduction | TomTom SDK for Android