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

SDK Registry token build error on Android #663

Closed
philiplindberg opened this issue Jul 1, 2021 · 7 comments
Closed

SDK Registry token build error on Android #663

philiplindberg opened this issue Jul 1, 2021 · 7 comments
Labels

Comments

@philiplindberg
Copy link
Contributor

I'm getting a SDK Registry token is null build error when running the app on Android, v0.12.0. Here's the entire debug message:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/philiplindberg/Code/flutter/.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 '/Users/philiplindberg/Code/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 346

* 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

I tried setting the Mapbox secret token according to the official Android docs, but to no avail. Thoughts?

flutter doctor -v output ``` [✓] Flutter (Channel stable, 2.2.2, on macOS 11.3 20E232 darwin-x64, locale en-US) • Flutter version 2.2.2 at /Users/philiplindberg/Code/flutter • Framework revision d79295af24 (3 weeks ago), 2021-06-11 08:56:01 -0700 • Engine revision 91c9fc8fe0 • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at /Users/philiplindberg/Library/Android/Sdk
• Platform android-30, build-tools 30.0.0
• ANDROID_HOME = /Users/philiplindberg/Library/Android/Sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.57.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.23.0

[✓] Connected device (4 available)
• Pixel 3 (mobile) • 96KX221LS • android-arm64 • Android 11 (API 30)
• Philip's iPhone (mobile) • 00008020-00151D9C3682002E • ios • iOS 14.6
• macOS (desktop) • macos • darwin-x64 • macOS 11.3 20E232 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114

• No issues found!

</details>
@gabeschine
Copy link
Contributor

This pull request will fix your issue: #644

@gabeschine
Copy link
Contributor

My apologies. This PR follows the official Android documentation: #621

644 allows the instructions for iOS to work on both platforms (I prefer this approach).

@b3arco
Copy link

b3arco commented Sep 9, 2021

If you're still struggling with this (and as the above mentioned PRs are not merged):
You need an SDK Registry Token.

You can get that from https://account.mapbox.com/access-tokens
Create a new token and only select DOWNLOADS:READ.
Then add it to your shell resource file (.zshrc or similar) as

export SDK_REGISTRY_TOKEN="sk.xxxxxxxxxxxx"

Restart your IDE and it should work fine.

@nalnir
Copy link

nalnir commented Oct 11, 2021

If you're still struggling with this (and as the above mentioned PRs are not merged): You need an SDK Registry Token.

You can get that from https://account.mapbox.com/access-tokens Create a new token and only select DOWNLOADS:READ. Then add it to your shell resource file (.zshrc or similar) as

export SDK_REGISTRY_TOKEN="sk.xxxxxxxxxxxx"

Restart your IDE and it should work fine.

I still get the same error. I made sure the token has only DOWNLOADS:READ checked and that I added the line in .zshrc and restarted the IDE.

@psatler
Copy link

psatler commented Oct 30, 2021

Hello everyone!

I've also got this working by combining previous answers and other answers I've found on the internet. Below is the solution I got:

ANDROID

  • for Android, I've done two approaches, but I'm going to stick with the last one for debugging reasons.
    1. You can set at the project's file found at android/gradle.properties the variable MAPBOX_DOWNLOADS_TOKEN with your token. So, something like MAPBOX_DOWNLOADS_TOKEN=sk.xxxxx. This will work if you run the project via terminal, for example, flutter run -t lib/main_dev.dart -flavor dev. However, you won't be able to debug on vscode. At least, I couldn't do it with this approach
    2. Another way was to use the env property of the launch.json file to expose the environment variable SDK_REGISTRY_TOKEN to the flutter/dart process when running via vscode. This way you can still use vscode to debug your code. For example:
    {
      "env": {
        "SDK_REGISTRY_TOKEN": "sk.xxxxxxxx",
      },
      "name": "Launch development",
      "program": "lib/main_dev.dart",
      "request": "launch",
      "type": "dart",
      "args": [
        "--flavor",
        "dev",
        "--target",
        "lib/main_dev.dart"
      ],
    },
    

iOS

  • for iOS, I followed the instructions found at this link at the "Configure your public token" section. I also had a problem with "Xcode 12 dylib error" which I could solve by adding this to my podfile.

@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 the stale label Jan 14, 2022
@k-achraf
Copy link

Add this line to your gradle.properties file:
MAPBOX_DOWNLOADS_TOKEN=YOUR MAPBOX DOWNLOADS ACCESS TOKE

Follow this documentation to create your token:
https://docs.mapbox.com/android/maps/guides/install/

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

No branches or pull requests

6 participants