maps icon indicating copy to clipboard operation
maps copied to clipboard

Maplibre failing on build

Open d3vv3 opened this issue 5 years ago • 13 comments

Describe the bug

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.
     Required by:
         project :app > org.maplibre.gl:android-sdk:9.4.0
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.
         > Could not get resource 'https://dl.bintray.com/maplibre/maplibre-gl-native/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom'.
            > Could not HEAD 'https://dl.bintray.com/maplibre/maplibre-gl-native/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom'. Received status code 403 from server: Forbidden
   > Could not resolve com.mapbox.mapboxsdk:mapbox-sdk-turf:5.3.0.
     Required by:
         project :app > org.maplibre.gl:android-sdk:9.4.0
         project :app > project :react-native-mapbox-gl_maps
      > Could not resolve com.mapbox.mapboxsdk:mapbox-sdk-turf:5.3.0.
         > Could not get resource 'https://dl.bintray.com/maplibre/maplibre-gl-native/com/mapbox/mapboxsdk/mapbox-sdk-turf/5.3.0/mapbox-sdk-turf-5.3.0.pom'.
            > Could not HEAD 'https://dl.bintray.com/maplibre/maplibre-gl-native/com/mapbox/mapboxsdk/mapbox-sdk-turf/5.3.0/mapbox-sdk-turf-5.3.0.pom'. Received status code 403 from server: Forbidden

To Reproduce

With Mapbox SDK it works fine, but Maplibre is giving me issues.

  • On android/app/build.gradle I have the following:
dependencies {
    // ...
    // Added for Maplibre
    implementation 'org.maplibre.gl:android-sdk:9.4.0'
    // ...
}
  • On android/build.gradle I have the following:
buildscript {
    ext {
        // ...
        rnmbglMapboxLibs = {
            implementation ("org.maplibre.gl:android-sdk:9.2.1")
            implementation ("com.mapbox.mapboxsdk:mapbox-sdk-turf:5.3.0")
        }
        rnmbglMapboxPlugins = {
            implementation ("com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0")
            implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0")    {
                exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
            }
            implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0")        {
                exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
            }
            implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0") {
                exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
            }
        }
    }
}

repositories {
    // ...
    maven {
        url = "https://dl.bintray.com/maplibre/maplibre-gl-native"
    }
}

Expected behavior
App to build normally with open-source Maplibre working just fine. Actual behavior
Build stops with the output given above.

Versions (please complete the following information):

  • Platform: Android
  • Platform OS: Android 11
  • Device: Oneplus 5T
  • Emulator/ Simulator: No
  • Dev OS: Debian Bullseye
  • react-native-mapbox-gl Version 8.3.0
  • Mapbox GL version ?????
  • React Native Version 0.65.1

Additional context
None

d3vv3 avatar Sep 10 '21 22:09 d3vv3

I see that this is solved when using a token. But wasn't it supposed to be free (libre)?

d3vv3 avatar Sep 16 '21 17:09 d3vv3

hmm, not sure I quite follow

settings in android/build.gradle look fine to me. why do you additionally add implementation 'org.maplibre.gl:android-sdk:9.4.0' in android/app/build.gradle ?? 🤔

ferdicus avatar Sep 17 '21 11:09 ferdicus

Without that line the issue is still the same.

I added it because of the maplibre documentation, but I removed it.

I thought I could use the library completely open source without token from Mapbox.

d3vv3 avatar Sep 17 '21 12:09 d3vv3

can you please try to reproduce it with the example application

only have to set this to true: https://github.com/react-native-mapbox-gl/maps/blob/c680562d3eb2a2043a5e738326bc61f95d51d5dc/example/android/build.gradle#L11

ferdicus avatar Sep 17 '21 13:09 ferdicus

Just tried, with the accesstoken file blank. It compiles, but the map is always black because:

 ERROR  Mapbox error {mapboxglexample}[Setup]: loading style failed: A valid access token parameter is required when using a Mapbox service.
Please see https://www.mapbox.com/help/create-api-access-token/ to learn how to create one.
More information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens.Currently provided token is:  {"level": "error", "message": "{mapboxglexample}[Setup]: loading style failed: A valid access token parameter is required when using a Mapbox service.
Please see https://www.mapbox.com/help/create-api-access-token/ to learn how to create one.
More information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens.Currently provided token is: ", "tag": "Mbgl"}

Is there any example with Maplibre flavours or styling?

d3vv3 avatar Sep 17 '21 23:09 d3vv3

Are you trying to access Mapbox tiles? You can not use the tile service without having a valid accessToken.

You can use the library without any token - you can not use tile data without having a valid accessToken.

Makes sense?

ferdicus avatar Sep 24 '21 07:09 ferdicus

I am getting the same errors, i see in the maplibre docs that they stopped using bintray and moved to mavenCentral

wake-up-jelle avatar Oct 07 '21 20:10 wake-up-jelle

I'll give this another try when upgrading the /example app to RN 0.66, will report back

ferdicus avatar Oct 08 '21 07:10 ferdicus

Thank you! Would love to use maplibre since my app is only showing locally downloaded map tiles.

wake-up-jelle avatar Oct 08 '21 09:10 wake-up-jelle

Just finished testing and can verify, that it works (with a caveat - see below), this my setup:

Dev machine: OSX 11.6 (intel chip)
XCode version: 13
RN: 0.66
react-native-mapbox-gl/maps: 8.3.0
MapLibre version: 9.2.1
node: v14.15.0
cocoapods: 1.11.2

The caveat: as @jbreuer95 correctly pointed out some dependencies got moved.

Make sure to include (next to all the other default react-native init dependency repositories within android/build.gradle): jcenter()

your android/build.gradle should look something like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"


        rnmbglMapboxLibs = {
            implementation ("org.maplibre.gl:android-sdk:9.2.1")
            implementation ("com.mapbox.mapboxsdk:mapbox-sdk-turf:5.3.0")
        }

        rnmbglMapboxPlugins = {
            implementation ("com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0")
            implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0")    {
                exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
            }
            implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0")        {
                exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
            }
            implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0") {
                exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
            }
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        maven { url 'https://www.jitpack.io' }
+       jcenter()
    }
}

Let me know how it works out for you 👍🏿

will update the install guide as soon as you reply

ferdicus avatar Oct 08 '21 14:10 ferdicus

Thank you. I cannot fix speak for @d3vv3 but I had the same build problem, and making the change in @ferdicus comment fixed my build issues.

Hergeirs avatar Nov 20 '21 14:11 Hergeirs

Adding jcenter was the only way for me to get the build working also.

Any plans or ideas when jcenter will (soon?) be shutdown? Anything that can be done in the build scripts to exclude this mapbox sdk dependency when using maplibre option?

tomihuttunen avatar Feb 04 '22 08:02 tomihuttunen

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 18 '22 18:04 stale[bot]