i am getting a authorization error when using mapbox in react native
https://api.mapbox.com/downloads/v1/navigation/android/maven/com/mapbox/navigation/ui/1.5.0/ui-1.5.0.pom'. Received status code 401 from server: Unauthorized
i am using the package ( https://www.npmjs.com/package/#homee/react-native-mapbox-navigation )
according package documentation i am doing the same.
my build.gradle file is
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
maven {
url 'https://api.mapbox.com/downloads/v1/navigation/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
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()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
maven { url 'https://www.jitpack.io' }
maven {
url 'https://api.mapbox.com/downloads/v1/navigation/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
}
I recently encountered a similar issue. My first advice would be that if you're using their public Access token, create a new one from Access Tokens and make sure Downloads:Read scope is checked. Then create a gradle.properties file in "your_projects_directory.gradle" (which to me was C:\Users\USERNAME\AndroidStudioProjects\ .gradle), and paste the following line:
MAPBOX_DOWNLOADS_TOKEN=YOUR_SECRET_ACCESS_KEY
You should replace YOUR_SECRET_ACCESS_KEY with your actual access key of course. Just in case Android Studio is unable to find this newly created gradle.properties file, I would recommend adding a duplicate of the above line to your project gradle.properties file [This was what fixed my issue] although I'm not sure if this has any security implications.
Then finally your build.gradle should contain this:
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = System.getenv("MAPBOX_DOWNLOADS_TOKEN") ?: project.property("MAPBOX_DOWNLOADS_TOKEN") as String
}
}
Related
I have issue in build.gradle first i got DSO error tht i solved by using custom plugin and added into app.json but after that I got another error like No static method createEGl14 so I updated the minSdkVersion = 24 but that lead me to the again DSO problem.
//build.gradle
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
// minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
minSdkVersion = 24
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
if (System.properties['os.arch'] == 'aarch64') {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = '24.0.8215888'
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = '21.4.7075529'
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.2.1')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('de.undercouch:gradle-download-task:5.0.1')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup 'com.facebook.react'
}
}
maven { url 'https://www.jitpack.io' }
}
}
//custome plugin to solve DSO issue.
const {
createRunOncePlugin,
withAppBuildGradle,
} = require("#expo/config-plugins");
const withAppBuildGradleModified = (config) => {
return withAppBuildGradle(config, async (file) => {
const modResults = file.modResults;
modResults.contents =
modResults.contents +
"\nandroid.packagingOptions.jniLibs.useLegacyPackaging = true\n";
return file;
});
};
module.exports = createRunOncePlugin(
withAppBuildGradleModified,
"withAppBuildGradleModified",
"1.0.0"
);
//app.json
{
"expo": {
"name": "videocall_webrtc",
"slug": "videocall_webrtc",
"version": "1.0.0",
"assetBundlePatterns": ["**/*"],
"plugins": ["./plugin.js", "#config-plugins/react-native-webrtc"]
}
}
Could you please help me how to resolve this issue. I am using JDK 11 and not using EAS build it is an Bare expo project. Could you please share any example or anything that could help me. Thank you in advance.
I am in the process of trying to build a preview Android version using EAS build, but when I run eas build -p android --profile android-preview I get this error:
[stderr] A problem occurred evaluating project ':unimodules-core'.
[stderr] >
[stderr] Plugin with id 'maven' not found.
Now I see people are suggesting replacing this:
apply plugin: 'maven'
With this, in the build.gradle file:
apply plugin: 'maven-publish'
But I don't find that reference to maven anywhere in my project. And my build.gradle file looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
kotlinVersion: '1.6.20'
if (System.properties['os.arch'] == 'aarch64') {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = '24.0.8215888'
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = '21.4.7075529'
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.2.1')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('de.undercouch:gradle-download-task:5.0.1')
classpath('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup 'com.facebook.react'
}
}
maven { url 'https://www.jitpack.io' }
}
}
How can I resolve this? Any help would be appreciated.
I'm upgrading the React Native version to the 0.69.3. And when I try to run on android. I get this error:
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven9(http://repo.brightcove.com/releases)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
I tried the following solutions:
Add the allowInsecureProtocol = true param.
Just add the s on the http.
But still throw me this error.
This is my code in that part:
allprojects {
repositories {
mavenLocal()
maven {
url("$rootDir/../node_modules/react-native/android")
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
mavenCentral {
content {
excludeGroup "com.facebook.react"
}
}
google()
jcenter()
maven { url 'https://repo.brightcove.com/releases' }
maven {
url "http://repo.brightcove.com/releases"
allowInsecureProtocol = true
}
maven { url 'https://maven.google.com' }
maven { url "https://www.jitpack.io" }
}
}
I have two github pacakges named XXX/AAA and YYY/BBB (same OWNER but different repository).
Now, when I try to add them into my project, gradle always seem to use the 1st repository.
repositories {
maven { url 'https://jitpack.io' }
maven {
url "https://maven.pkg.github.com/XXX/AAA"
credentials {
username = USERNAME
password = PWD
}
}
maven {
url "https://maven.pkg.github.com/XXX/BBB"
credentials {
username = USERNAME
password = PWD
}
}}
And com.example in implementation is also same.
dependencies {
// implementation 'com.example:package'
// AAA
implementation("YYY:AAA:${a_version}")
// BBB
implementation("YYY:BBB:${b_version}")
}
and I receive the following error while syncing
Could not HEAD 'https://maven.pkg.github.com/XXX/AAA/YYY/BBB/0.1/BBB-0.1.pom'. Received status code 400 from server: Bad Request. Disable Gradle 'offline mode' and sync project
As we can clearly see, gradle uses the wrong repository(AAA instead of BBB)
Any help is appreciated.
Thanks in advance
You need to declare these repositories as exclusive for the respectful dependencies:
repositories {
maven { url 'https://jitpack.io' }
exclusiveContent {
forRepository {
maven {
url 'https://maven.pkg.github.com/XXX/AAA'
credentials {
username = "USERNAME"
password = "PWD"
}
}
}
filter {
includeModule("YYY", "AAA")
}
}
exclusiveContent {
forRepository {
maven {
url 'https://maven.pkg.github.com/XXX/BBB'
credentials {
username = "USERNAME"
password = "PWD"
}
}
}
filter {
includeModule("YYY", "BBB")
}
}
}
I am all new to Kotlin and gradle and wanted to create a reddit scraper app for fun.
Cant get the guide from this page to work.
https://mattbdean.gitbooks.io/jraw/content/quickstart.html
The guide tells me to put this in the gradle file:
repositories {
jcenter()
}
dependencies {
compile "net.dean.jraw:JRAW:$jrawVersion"
}
But when i put that in my buid.gardle.kts file the ide reports an error
See image below of where the error occurs. The error message is Unexpected tokens.
Found the answer to my question, simply had to add in the variable in the gradle file...
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
var jrawVersion = "1.1.0" //needed to add this in obviously
plugins {
kotlin("jvm") version "1.4.21"
application
}
group = "me.jeppe"
version = "1.0"
repositories {
mavenCentral()
jcenter()
}
dependencies {
testImplementation(kotlin("test-junit"))
compile ("net.dean.jraw:JRAW:$jrawVersion")
}
tasks.test {
useJUnit()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClassName = "MainKt"
}