Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Maven in Android Studio?

Tags:

There are lot of Answers on how to use Maven in Android and work with it.

However, As Gradle being already available, which manages the build process of Android projects and support complex scenarios in creating Android applications, such as Multi-distribution and Multi-apk,

What exactly is the role of Maven in Android Studio?

And how is it different from Gradle?

like image 551
OBX Avatar asked Oct 19 '15 03:10

OBX


People also ask

What is Android Maven?

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 and why it is used?

Maven is a popular open-source build tool developed by the Apache Group to build, publish, and deploy several projects at once for better project management. The tool provides allows developers to build and document the lifecycle framework.

Can we use Maven in Android Studio?

You can run Maven to build the project from Android Studio. You are now ready to develop!

What is meant by Maven?

Definition of maven : one who is experienced or knowledgeable : expert a language maven policy mavens computer mavens also : freak sense 4a.


1 Answers

The short answer is: The tools do the same thing but in different ways. The difference is how you can use them to build your project. Apache Maven goes for "follow our convention" way and Gradle gives you flexibility. Some devs don't want a new tool or don't have time to learn how to use it properly.

Now the long answer...

To understand properly why some devs are attached to Apache Maven, we have to look at some years in the past.

Apache Maven is a build automation tool just like Gradle.

Maven got released on 2004. Gradle first version got out on 2007 but it did not become as popular as Maven in the early days. Some devs don’t like having to learn anything new and most companies don't want to risk the exchange of an already running and mastered tool (Maven) for the new kid on the block.

Gradle became popular when the Android development raised. Android's project has a different project structure from Java EE/Web projects. Trying to use Maven on Android's project just feels unnatural, the tool was not prepared to provide flexibility.

Until now, Apache Maven can be used on simple Java EE projects without being a pain in the ass if you already know the forced conventions. So devs that aren't aware of Gradle/did not get in touch with Android apps don't have motivation to change to another tool.

In my opinion, Gradle is better than Apache Maven in every way that you could imagine. It gives you flexibility and tries not to get in your way, a "feature" that you cannot find in Apache Maven. If you don't follow Apache Maven life cycle, your build will fail, that's it.

For example, your code can be spread across many directories in any kind of layout if you are using Gradle. If you are on Maven and you don't follow the 'convention', you'll lose some hours changing your pom (Maven's build file) to be able to understand and handle your folder structure.

E.g.: Java source code must be on src/main/java folder. If you got an old project and the structure is src/java, sorry, You have no guarantee that all Maven plugins will run as expected.

Gradle does us a favor and puts more features for comparison in a very organized chart. Take a look. https://gradle.org/maven_vs_gradle/

like image 64
Bruno Avatar answered Oct 14 '22 20:10

Bruno