14

I am new to Android Studio. I am using libraries in my project. The maven central has updated version of facebook sdk, while rest of libraries I am using are available on jcenter. I want to know if we can use both these repositories in our project. If yes, then how do I need it to define in gradle file so that studio downloads aar from correct location. Any example would be helpful.

Nitish Kumar
  • 141
  • 1
  • 1
  • 4

3 Answers3

46

and for maven just add to your pom.xml:

<repositories>
    <repository>
      <id>jcenter</id>
      <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>
erank
  • 501
  • 4
  • 3
24

You never need both. JCenter is a superset of Maven Central, and it should suffice for all the dependencies.


I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.

asgs
  • 3,928
  • 6
  • 39
  • 54
JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • is this tested and verified? if the repo in its readme specified adding mavencentral and i just add jcenter it will get it and always get the right one? – Viral Patel Jan 18 '16 at 12:27
  • 2
    Yes it will. It's the default in Android Studio generated scripts (when you start a new project, for example), and it works great for everybody. – JBaruch Jan 18 '16 at 18:46
  • btw, an off-topic comment. Can you point me to a good tutorial to get started with BinTray? Would really appreciate it. – Viral Patel Jan 18 '16 at 18:48
  • 2
    @AndroidMechanic this one is good - https://medium.com/@ryanseys/publishing-to-maven-central-and-jcenter-2b6376424856#.ra7c3r8mc – JBaruch Jan 19 '16 at 19:57
  • //You never need both// - not always true; I found this [ojdbc.jar](https://mvnrepository.com/artifact/com.oracle/ojdbc14/10.2.0.4.0) in maven repo but not in jcenter. – KrishPrabakar Mar 04 '21 at 09:48
3

Yes you can use both repositories even though you don't need both unless you want to work offline.

Go to your build.gradle file in your app folder and type the following code:

buildscript 
{
repositories 
{
    jcenter{ url "http://jcenter.bintray.com/" }
    maven { url 'http://repo1.maven.org/maven2' }
}
dependencies 
{
    classpath 'com.android.tools.build:gradle:1.3.0'
}
}

allprojects 
{
repositories 
{
    jcenter()
}
}
Keerthi Mukku
  • 113
  • 1
  • 1
  • 9