Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple maven repositories in Gradle

I have the following build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }

        maven {
            url "https://dl.bintray.com/fyber/maven"
        }

        maven {
            url "https://dl.bintray.com/supersonic/android-sdk"
        }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.19.1'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

dependencies {
// Ads
      compile 'com.supersonic.sdk:mediationsdk:6.1.0@jar'
}

And I'm getting this error:

Error:(88, 13) Failed to resolve: com.supersonic.sdk:mediationsdk:6.2.0

I've checked that library exists in the repository. Why am I getting this error?

like image 464
artem Avatar asked Jul 30 '15 16:07

artem


People also ask

Can Gradle use Maven repositories?

Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project.

Can you mix Maven and Gradle?

Short answer: yes. There's no conflict between having two independent build scripts for the same project, one in Maven and one in Gradle.


1 Answers

You added those repositories to the buildscript list of repositories. Hence, those repositories are only used for the dependencies listed in buildscript.

You need a repositories closure outside of buildscript, listing the repositories where your top-level dependencies reside. So, probably what you want is something like:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }

        maven {
            url "https://dl.bintray.com/fyber/maven"
        }   
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.19.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

repositories {
        maven {
            url "https://dl.bintray.com/supersonic/android-sdk"
        }
}

dependencies {
// Ads
      compile 'com.supersonic.sdk:mediationsdk:6.1.0@jar'
}
like image 176
CommonsWare Avatar answered Oct 09 '22 19:10

CommonsWare