Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Maven repository in Android Studio?

Can anyone explain clairly what is Maven repository in Android Studio ? I try to understand it but I don't find better explainations. Last time I needed to add some dependencies in my project and they didn't work untill I added a link to Maven and Jcenter in my build.gradle file.

It worked parfectly but my question is just to know What is exactly maven and Jcenter in Android Studio ? Thanks in advance with your answers.

like image 704
Félix Maroy Avatar asked Jun 14 '19 08:06

Félix Maroy


People also ask

What is Maven repository used for?

A repository in Maven holds build artifacts and dependencies of varying types. There are exactly two types of repositories: local and remote: the local repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.

What is Maven in Android Studio?

The Android Maven Plugin is used to build applications for the Android operating system as well as build libraries to be used in these efforts in AAR and the legacy APKLIB format using Apache Maven. The plugin includes numerous features with some minimal setup for usage.

What is Maven used for in Android?

Maven is chiefly used for Java-based projects, helping to download dependencies, which refers to the libraries or JAR files. The tool helps get the right JAR files for each project as there may be different versions of separate packages.

What are repositories in Android Studio?

A repository class isolates data sources, such as a Room database and web services, from the rest of the app. The repository class provides a clean API for data access to the rest of the app. Using repositories is a recommended best practice for code separation and architecture.


2 Answers

A maven repository is a "repo", public or private, to store libraries, plugins and in general artifacts.
It is not related to Android Studio or another IDE.

JCenter is one of the maven repo.

JCenter is the place to find and share popular Apache Maven packages for use by Maven, Gradle, Ivy, SBT, etc.

Other common repo used in Android are:

  • Maven Central
  • Google maven repo

In a gradle script you can find them in the repositories block:

/**
     * The repositories block configures the repositories Gradle uses to
     * search or download the dependencies. Gradle pre-configures support for remote
     * repositories such as JCenter, Maven Central, and Ivy. You can also use local
     * repositories or define your own remote repositories. The code below defines
     * JCenter as the repository Gradle should use to look for its dependencies.
     *
     * New projects created using Android Studio 3.0 and higher also include
     * Google's Maven repository.
     */
repositories {
        google()
        jcenter()
    }
like image 67
Gabriele Mariotti Avatar answered Oct 20 '22 11:10

Gabriele Mariotti


Im not Java guy but from fast lookup in google:

Maven is build and dependency management tool (helps in building project and downloading dependencies).

Jcenter looks like repository of available libraries (is source for all dependencies downloaded by maven processes).

like image 20
Xesenix Avatar answered Oct 20 '22 11:10

Xesenix