Could not find com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0 - gradle

I have created the account and key needed from Mapbox. I have listed the repositories in different order with no luck. Whn building, the following error appears:
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom
- https://repo.maven.apache.org/maven2/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom
Required by:
project :app > com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1
Here's my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.20"
repositories {
google()
mavenCentral()
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
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've added the following to my module level build.gradle
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1'

I have only added jcenter() and it works. However, jcenter() is deprecated.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

It seem like they remove mapbox-android-accounts repository.
Check this: https://mvnrepository.com/artifact/com.mapbox.mapboxsdk/mapbox-android-accounts/0.8.0
Github page is empty.

Works for me after jcenter() added.
I added jcenter() to buildscript -> repositories and allprojects -> repositories:
// 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"
}
repositories {
google()
jcenter()
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 {
jcenter()
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")
}
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username "mapbox"
password "YOUR_TOKEN"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}

Related

What is the correct way of changing jcenter to mavenCentral?

I am working on an old project and Android Studio recommended me to update to mavenCentral().
I had this code:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And I have changed it to this one:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now my question is, is it enough just changing jcenter() for mavenCentral() to update from jcenter to mavenCentral like I have done or should I make something else to update from jcenter to mavenCentral?
Yeah, it should be enough just changing jcenter() to mavenCentral() if your project is building successfully.
If not then you need to check what missing library in mavenCentral is failing your build. Then learn which ways you have to fix it, for some libs you will need to use jitpack, for others upgrade to a version (where the author migrated it to mavenCentral), or host it locally in the project, etc.
Also, don't forget to do it for build.gradle in your other modules (not only root).

Could not find com.github.searchy2:CustomButton:1.9.0. ERROR

My build.gradle file looks like this:
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
maven { url 'https://plugins.gradle.org/m2/' }
jcenter() // Warning: this repository is going to shut down soon
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ERROR
Could not find com.github.searchy2:CustomButton:1.9.0.
Required by:
project :app > com.github.searchy2:CustomPermissionsDialogue:2.2.1

Upgrade kapt "com.android.databinding:compiler:XXX" -> error: cannot find symbol

Android Studio 3.2, Gradle 4.6
In my build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.BUTTER_KNIFE_VERSION = '8.8.1'
ext.GLIDE_VERSION = '4.2.0'
ext.KOTLIN_VERSION = '1.2.41'
ext.REALM_VERSION = '4.1.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.realm:realm-gradle-plugin:$REALM_VERSION"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
In my app/build.gradle:
kapt "com.android.databinding:compiler:3.1.2"
And my Android project success build and run.
Nice.
Now I upgrade to last version of plugins:
buildscript {
ext.BUTTER_KNIFE_VERSION = '8.8.1'
ext.KOTLIN_VERSION = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "io.realm:realm-gradle-plugin:$REALM_VERSION"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
}
}
in app/build.gradle:
kapt "com.android.databinding:compiler:3.1.4"
Project success build but when I run project I get error:
:app:kaptGenerateStubsDebugKotlin
e: myproject\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\com\myproject\databinding\AdvertisingBinding.java:25: error: cannot find symbol
protected AdvertisingBinding(DataBindingComponent _bindingComponent, View _root,
^
symbol: class DataBindingComponent
location: class AdvertisingBinding
I try Invalidate cache / Restart but it not help.

Sibling project seems not using it's dependency's build.gradle script

I have multi-module project with a structure like this:
|fullstack
\backend
|build.gradle
\frontend
|build.gradle
|build.gradle
|settings.gradle
Settings.gradle:
rootProject.name = 'fullstack'
include 'backend'
include 'frontend'
backend depends on ktor, so it's build.gradle contains repository:
maven { url "https://dl.bintray.com/kotlin/ktor" }
And backend module builds well.
Then I want to share some common classes between backend and frontend. I could make third module api and make others depend on it. But now I want to avoid third module and just make frontend to depend on backend.
I added the dependency to the frontend's gradle.build:
compile project (':backend')
and tried to build the whole project, but got an error:
Could not resolve all files for configuration
':frontend:compileClasspath'.
Could not find io.ktor:ktor-server-netty:0.9.1. Searched in the following locations:
https://repo.maven.apache.org/maven2/io/ktor/ktor-server-netty/0.9.1/ktor-server-netty-0.9.1.pom
https://repo.maven.apache.org/maven2/io/ktor/ktor-server-netty/0.9.1/ktor-server-netty-0.9.1.jar
Required by:
project :frontend > project :backend
It obviously didn't scan repositories of backend module. Why?
UPDATE
I've added repositories as said in answers. But when I try to import in frontend/main.kt any class from backend I get:
:frontend:compileKotlin2Jse: D:\...\frontend\src\main\kotlin\main.kt: (1, 8): Unresolved reference: com
e: D:\...\frontend\src\main\kotlin\main.kt: (2, 8): Unresolved reference: com
How to make it visible for frontend?
Root build.gradle:
group 'com.norg.parts'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_ver = '1.2.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_ver"
}
}
allprojects {
project.ext {
kotlin_version = kotlin_ver
ktor_version = '0.9.1'
}
repositories {
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/ktor' }
maven { url 'https://dl.bintray.com/kotlin/kotlinx' }
maven { url 'https://mvnrepository.com/artifac/' }
maven { url "https://dl.bintray.com/kotlin/exposed" }
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.8
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jar {
manifest {
attributes 'Main-Class': 'com.norg.parts.MainKt'
}
//TODO include jar from frontend!
}
The problem is that there can be 2 dependencies / repositories blocks. The first one is in the buildscript which looks like this:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
This is responsible for setting up tooling and plugins. Then when you set up the config of your project itself you can do several things. If you don't have a multi-module project you just dump it into your build.gradle then the file looks like this:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
dependencies {
compile "io.ktor:ktor-server-core:$ktor_version"
}
In your case you should use either allprojects which means that all configuration which you put in that block will be applied to all your projects (including root), or subprojects. In the latter case, the block will be applied to only your subprojects (root not included). This looks like this:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
subprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
dependencies {
compile "io.ktor:ktor-server-core:$ktor_version"
}
}
Your problem is that you did not add the repository itself to your project config, only your buildscript config.
If you are planning to mix frontend and backend code you can now use Kotlin Multiplatform Projects. I've written about this here.
Response to your edit:
You really need to move all this to a subprojects block:
subprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.8
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jar {
manifest {
attributes 'Main-Class': 'com.norg.parts.MainKt'
}
//TODO include jar from frontend!
}
}
and you also need to add the backend project as a dependency to your frontend project in that project's build.gradle. I'd strongly advise you to read the Gradle Documentation since this is a Gradle issue not a Kotlin issue whatsoever.
Dependencies are transitive, but repositories are not. This is why most projects have a allprojects block in the root build file defining the repositories for all subprojects at the same time.

gradle plugin dependencies not found under buildSrc

I have a working build.gradle that I'd like to refactor into the buildSrc directory but I'm having trouble finding the dependencies.
Working build.gradle:
import groovyx.net.http.HTTPBuilder
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.2'
}
}
plugins {
id 'groovy'
}
group "com.example"
version "0.0.1"
class Foo {
Foo() {
new HTTPBuilder('http://www.example.com')
}
}
Non-working refactored build.gradle:
However, when I try to split into the following:
build.gradle
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.2'
}
}
plugins {
id 'groovy'
}
group "com.example"
version "0.0.1"
and buildSrc/src/main/groovy/Foo.groovy
import groovyx.net.http.HTTPBuilder
class Foo {
Foo() {
new HTTPBuilder('http://www.example.com')
}
}
Gives the error:
C:\Project\buildSrc\src\main\groovy\Foo.groovy: 7: unable to resolve
class HTTPBuilder # line 5, column 26.
HTTPBuilder client = new HTTPBuilder('http://www.example.com')
How can I get gradle to recognise the dependencies?
You need to create a build.gradle file for buildSrc directory. Try this:
C:\Project\buildSrc\build.gradle
apply plugin: 'groovy'
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.2'
}
There is more details in this documentation section.

Resources