Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.12.0 A problem occurred evaluating project ':mapbox_gl'. #604

Closed
4F2E4A2E opened this issue Apr 12, 2021 · 44 comments
Closed

v0.12.0 A problem occurred evaluating project ':mapbox_gl'. #604

4F2E4A2E opened this issue Apr 12, 2021 · 44 comments

Comments

@4F2E4A2E
Copy link

Once again, thank you for this lib.

I just did try out an upgrade to the latest v0.12.0, this is the result on trying to build it:

Launching lib\main.dart on sdk gphone x86 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\Acme\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\mapbox_gl-0.12.0\android\build.gradle' line: 18

* What went wrong:
A problem occurred evaluating project ':mapbox_gl'.
> SDK Registry token is null. See README.md for more information.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* Where:
Script 'C:\work\tools\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 325

* What went wrong:
A problem occurred configuring project ':mapbox_gl'.
> Could not get unknown property 'android' for project ':mapbox_gl' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

flutter v2.0.4
android api v30

https://github.com/tobrun/flutter-mapbox-gl/releases/tag/0.12.0

P.s.: the same project is working fine on v0.11.0

@fionawhim
Copy link

This is due to the Mapbox SDK needing a download token.

From what I can tell the way that this project’s build.gradle expects the token is in a SDK_REGISTRY_TOKEN environment variable.

Unfortunately I can’t find a way to set this using out-of-the-box Flutter / Gradle techniques. We have a closed-source app and would like to just save the key into source control rather than having all our devs add an environment variable to their shells to make the download work.

Is it possible to switch to using a gradle property or something to read the token?

@4F2E4A2E
Copy link
Author

It's really unfortunate. This is in my honest opinion, the best lib solution for flutter, but the race along or against the closed src seems to be a big problem in the long run.

I wonder what it would take to write a new solution from scratch in unity or sketcher for flutter.

@vrman
Copy link

vrman commented Apr 13, 2021

i got same error message. is there any solution to fix this ?

@Mushroomizer
Copy link

I have the same issue, i solved it temporarily by modifying C:\flutter.pub-cache\hosted\pub.dartlang.org\mapbox_gl-0.12.0\android\build.gradle

And setting my token there:

image

@vrman
Copy link

vrman commented Apr 13, 2021

I have the same issue, i solved it temporarily by modifying C:\flutter.pub-cache\hosted\pub.dartlang.org\mapbox_gl-0.12.0\android\build.gradle

And setting my token there:

image

now i got another error message :

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
     Required by:
         project :app > project :mapbox_gl
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
         > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.6.0/mapbox-android-sdk-9.6.0.pom'.
            > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.6.0/mapbox-android-sdk-9.6.0.pom'. Received status code 403 from server: Forbidden
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
     Required by:
         project :app > project :mapbox_gl > com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
         > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.6.0/mapbox-android-sdk-9.6.0.pom'.
            > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.6.0/mapbox-android-sdk-9.6.0.pom'. Received status code 403 from server: Forbidden
   > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
     Required by:
         project :app > project :mapbox_gl > com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0
         project :app > project :mapbox_gl > com.mapbox.mapboxsdk:mapbox-android-plugin-offline-v9:0.7.0
      > Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
         > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.6.0/mapbox-android-sdk-9.6.0.pom'.
            > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-sdk/9.6.0/mapbox-android-sdk-9.6.0.pom'. Received status code 403 from server: Forbidden


@Mushroomizer
Copy link

Mushroomizer commented Apr 13, 2021

Did you create a token here
https://account.mapbox.com/access-tokens/

You need to create a token and set its scopes (for debugging, Create a "test" token, set all the scopes to true. Then remove unneeded scopes and delete the test token later),
Note: You should copy the resulting "sk.****" token and store it in a safe place, you wont be able to read it again

@vrman
Copy link

vrman commented Apr 13, 2021

Did you create a token here
https://account.mapbox.com/access-tokens/

yes i have once ,
im also tried to change username in build.gradle from mapbox to my username but its not works again.
same error message

@Mushroomizer
Copy link

Mushroomizer commented Apr 13, 2021

Did you add all the secret scopes?
image

You should also do a flutter clean

@Mushroomizer
Copy link

PS. Dont change the username, it should be 'mapbox'

@Tkko
Copy link

Tkko commented Apr 13, 2021

I'm facing the same issue with self-hosted map provider.

@Mushroomizer
Copy link

Mushroomizer commented Apr 13, 2021

@Tkko Did you try editing C:\flutter.pub-cache\hosted\pub.dartlang.org\mapbox_gl-0.12.0\android\build.gradle and pasting your sk in there?

sk = secret key
example (Obviously this key is invalid, its so you can determine the format of the key you need to expect):
sk.eyT1IjoibXVzaHJv421tZGlmxWVyIiwiYSI6IxRrbmZyYah1YTJpGmbycnRhezMzMHR3bfQifQ.K9KerfvUM-IridFaojT2fQ

@vrman
Copy link

vrman commented Apr 13, 2021

Did you add all the secret scopes?
image

You should also do a flutter clean

It works now , thanks

@Tkko
Copy link

Tkko commented Apr 13, 2021

@Tkko Did you try editing C:\flutter.pub-cache\hosted\pub.dartlang.org\mapbox_gl-0.12.0\android\build.gradle and pasting your sk in there?

sk = secret key
example (Obviously this key is invalid, its so you can determine the format of the key you need to expect):
sk.eyT1IjoibXVzaHJv421tZGlmxWVyIiwiYSI6IxRrbmZyYah1YTJpGmbycnRhezMzMHR3bfQifQ.K9KerfvUM-IridFaojT2fQ

Do I still need mapbox access token if I use self-hosted map provider?

@Mushroomizer
Copy link

Mushroomizer commented Apr 13, 2021

Thats a separate issue.
@Tkko Not sure, im guessing you would need an access token that you generate on your self hosted solution instead of one from mapbox. You will need to contact mapbox for more info
.

@fionawhim
Copy link

Does anyone have suggestions for how to add the token for development without modifying the build.gradle file in .pub-cache or setting an environment variable?

What about switching to the official SDK’s technique, which pulls it off of project.properties? My very very cursory understanding of Gradle indicates that for CI you could then set an environment variable ORG_GRADLE_PROJECT_… to set it.

And then we could include our tokens either in a project root gradle.properties file or in a home directory.

@alparslana
Copy link

A few problems must be corrected anyways to guide the users:

  1. README.md shall be updated to indicate that an environment variable named SDK_REGISTRY_TOKEN shall be defined with the access key token.
  2. README.md shall be updated to indicate that the user creates a new access key token if the previously generated access key token does not start with sk. but rather starts with pk.. The current README.md indicates the following sentence but it gets carried away:
    You must also [configure a secret access token having the Download: read scope]
  3. The CHANGELOG.md shall be updated to have correct year for releases 0.10.0, 0.11.0, and 0.12.0 (year shall be 2021 and not 2020)

In addition, it would be great if the token can be propagated to build.gradle file of the library from a project file such as the build.gradle file of the project.

@alparslana
Copy link

Please review the fix and provide feedback over the pull request.

@kuhnroyal
Copy link

Maybe switch to https://github.com/maplibre/maplibre-gl-native :)

@raphaaugustosilva
Copy link

Any update on this?

@tobrun
Copy link
Collaborator

tobrun commented Apr 17, 2021

Thank you all for using this project and flagging this.

This lib is not exclusively to be used with the mapbox hosted maps, right?

That is correct you can use your own tile servers.

Do I still need mapbox access token if I use self-hosted map provider?

Yes, to make sure we are on the same page: the token is used to to authenticate against the Mapbox SDK registry. Which is a gateway to maven for android and cocaopods/carthage/spm for iOS. It allows this project to pull in the binaries coming from mapbox-gl-native-android and mapbox-gl-native-ios. The token is only used at compile time and isn't packaged with your application.

Does anyone have suggestions for how to add the token for development without modifying the build.gradle file in .pub-cache or setting an environment variable?

I will look into ways making this process more easy but if anyone has a suggestion, like a hook into how flutters builds and a clean way to inject it, please reach out!

A few problems must be corrected anyways to guide the users:

Thank you @alparslana for the comments and the PR, will review.

Maybe switch to https://github.com/maplibre/maplibre-gl-native :)

I appreciate the time people are putting into that library and keeping https://github.com/mapbox/mapbox-gl-native alive in the opensource. That said, I don't think this issue is the appropriate place to discuss this specific topic. Feel free to create a new ticket for this instead.

@4F2E4A2E
Copy link
Author

Thank you so much for clarifying.

Yes, to make sure we are on the same page: the token is used to to authenticate against the Mapbox SDK registry.

Until v0.11.0, I could build and use this lib without any problems. Does it mean that as from v0.12.0, this lib is only usable or buildable with a genuine token from mapbox?

@kuhnroyal
Copy link

@4F2E4A2E Yes

@4F2E4A2E
Copy link
Author

@tobrun do you confirm @kuhnroyal affirmation on my question?

@alex-lechner
Copy link

Yes, to make sure we are on the same page: the token is used to to authenticate against the Mapbox SDK registry.

@tobrun I'm using my own tile server and until v0.11.0 it was working perfectly fine without the Mapbox token so I don't quite understand the outcome of using it. Which benefits does the token provide to the community so it's worth taking the steps to create the token? Does this token solve a problem for the community or is it Mapbox trying to solve their own problems by enforcing the use of this token?

I'm asking this because I don't want to find myself in front of a paywall in a few months (due to API limits, etc.). So I either have to use v0.11.0 or fork this repo and pull all updates except for the token implementation, right?

@kuhnroyal
Copy link

The problem is that MapBox made its SDKs closed source. You can only download it from now on with a valid MapBox token.
This project includes the MapBox artifacts via the official download urls of the MapBox Android and iOS SDKs. So if you want to download them, you need a token.

You can probably also change the build somehow to include the MapBox SDKs from a local source. Then you don't need a token but you still need a MapBox account to download them.

Like @tobrun said, the token is only used for the download of the SDKs. Not for anything else. You can still use your own server, styles etc.
If you don't use any of the MapBox APIs, you should be fine, for now.

@alex-lechner Your only choice is to use 0.11.0. You can not just strip the token usage as you then don't have the Android/iOS native SDKs on which this plugin is based on.

@Makaooo
Copy link

Makaooo commented Apr 17, 2021

hi I found something in pull requests this is awesome and you don't need to add a key in env for android, you can read it from netrc file.
just like ios you can use it for ios and android

#609 (comment)

@raphaaugustosilva
Copy link

What`s the correct way to set this environment variable?

Editing the "flutter.pub-cache\hosted\pub.dartlang.org\mapbox_gl-0.12.0\android\build.gradle" file doesn't seem to be very useful because our team has 5 developers, and they would need to edit the same file at their local machine.

Has anyone managed to make it work without editing the pub-cache file?

@kuhnroyal
Copy link

@raphaaugustosilva For android you just export SDK_REGISTRY_TOKEN. For iOS you need to configure ~/.netrc according to the Mapbox iOS guidelines.
Both work for me but it is hard to configure for CI.

@hugoquintalcr
Copy link

I did that instructions but it couldn´t work, maybe I´ll waiting for a new version of that library :/

@4F2E4A2E
Copy link
Author

Have you tried https://github.com/maplibre/maplibre-gl-native ?

@javashaman
Copy link

For me, for android, adding the environment variable SDK_REGISTRY_TOKEN with my secret key to my .bash_profile did the trick. For iOS I had to setup the .netrc file as outlined on the mapbox sdk install page.

@syahrizalakbar
Copy link

Screen Shot 2021-04-22 at 17 18 31

simply just add SDK_REGISTRY_TOKEN to your environtment variable

@raphaaugustosilva
Copy link

Screen Shot 2021-04-22 at 17 18 31

simply just add SDK_REGISTRY_TOKEN to your environtment variable

How can I achieve this with CI/CD ?

@andrea689
Copy link
Collaborator

@raphaaugustosilva depends on your CI/CD.. if you use Github actions look at this: https://github.com/tobrun/flutter-mapbox-gl/blob/master/.github/workflows/flutter_ci.yml

@jkronlachner
Copy link

Adding it to my .bash_profile didn't work. For Android I had to add it manually to the packages gradle file.
iOS worked with the .netrc File.
Both isn't useful as we work as a team on this project...
Is there a way to define it project wise?

@alparslana
Copy link

Folks, this is not stackoverflow. Please post your questions on how to set environment variables on stackoverflow, and not here since they really do not help in the solution of the documented problem.

lduivenbode added a commit to lduivenbode/flutter-mapbox-gl that referenced this issue Apr 24, 2021
Updated build.gradle to reference gradle.properties, and to use MAPBOX_DOWNLOADS_TOKEN rather than SDK_REGISTRY_TOKEN. This makes it consistent with the Android installation instructions.

Also updated documentation to note this step as it's no longer iOS specific.
@lduivenbode
Copy link

lduivenbode commented Apr 24, 2021

This also bit me and I found the documentation to be misleading as it only mentions iOS. I've created a PR #621 that makes the necessary changes to build.gradle and README.md. As part of this I've also changed the variable name to MAPBOX_DOWNLOADS_TOKEN as that matches the existing Android installation docs.

@kuhnroyal
Copy link

Does anyone here know some Gradle way to override the project(':mapbox_gl').allprojects {} setup that is provided by the plugin. I want to manually add a custom repository with the Android SDK but the check for the environment variable is always running.

@kuhnroyal
Copy link

I came up with a way to use a private Maven repository for the artifacts that doesn't require a token.
By manually download the Android SDK artifacts and iOS SDK zip file + Podspec and uploading everything as Maven artifacts to a private repository.
Then using a local Podspec file with the Maven artifact URL for iOS and some Gradle configuration to replace the Mapbox repository provided by the plugin with the private repository.

@jkronlachner
Copy link

For people using codemagic for their CI builds:

For Android you just have to add the
SDK_REGISTRY_TOKEN variable to your env-variables.

For iOS i use this piece of pre-build-script:
# set up mapbox token echo -e "machine $NETRC_MAPBOX_MACHINE\nlogin $NETRC_MAPBOX_LOGIN\npassword $SKD_REGISTRY_TOKEN | base64 --decode" > ~/.netrc

Additionally i have added these to my env:
Env-Variables

But you could just write them directly into the script.

@lampian
Copy link

lampian commented Jun 3, 2021

From the original issue:

SDK Registry token is null. See README.md for more information.
...
P.s.: the same project is working fine on v0.11.0

Firstly, thanks to contributors for the flutter implementation.

I faced the same issue - added the following to launch.json:
"env": { "SDK_REGISTRY_TOKEN" : "sk.eyJ.....A" }
I also had to create a new dev token with all the secret flags set.
Seems to be working ok on droid platforms

@dsErick
Copy link

dsErick commented Jun 20, 2021

From the original issue:

SDK Registry token is null. See README.md for more information.
...
P.s.: the same project is working fine on v0.11.0

Firstly, thanks to contributors for the flutter implementation.

I faced the same issue - added the following to launch.json:
"env": { "SDK_REGISTRY_TOKEN" : "sk.eyJ.....A" }
I also had to create a new dev token with all the secret flags set.
Seems to be working ok on droid platforms

@lampian solution worked for me.
I just needed to add a env entry to .vscode/launch.json, and now it's working.
I only tested on android plataform.

@stale
Copy link

stale bot commented Jan 14, 2022

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 stale bot added stale and removed stale labels Jan 14, 2022
@Shiba-Kar
Copy link

in gridle.properties

add this MAPBOX_DOWNLOADS_TOKEN="sk.DFSDAD........."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests