Using jcenter and mavenCentral both in Android Stu

2020-02-12 02:26发布

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.

3条回答
倾城 Initia
2楼-- · 2020-02-12 02:48

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.

查看更多
我想做一个坏孩纸
3楼-- · 2020-02-12 02:54

and for maven just add to your pom.xml:

<repositories>
    <repository>
      <id>jcenter</id>
      <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>
查看更多
唯我独甜
4楼-- · 2020-02-12 02:59

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()
}
}
查看更多
登录 后发表回答