When to use Maven for an Android project? - android

I've been working in JSF projects for a couple years; from the standpoint of managing dependencies, maven was a huge time saver as projects may have up to 50 dependencies, and a large number of them were the same from project to project.
Now I'm developing Android projects, I noticed is unusual having more than 5 dependencies, and they're often vary from project to project; in much cases, I don't have a jar to import, but a Project library. So I'm managing my android projects dependencies manually, and didn't miss maven so far.
My questions are:
Is it always a good practice to use maven for any android project, even if it uses only a couple of external jars? Why? If not, when is it a good a time to think about using maven in a project?

Related

Is it possible to use Maven instead of Gradle in Android?

I want to remove gradle completely from my app, and start using Maven. I know that Gradle is the official and default way, but due to some restrictions, I need Maven. I have investigated but did not come up with a solution. Is is possible? How?
In case that it is possible, how can you set the different parameters? e.g. multiDexEnable, compileSdkVersion, buildTypes...
You can use the Android Maven Plugin
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.
It seems quite updated and there's also a GitHub page. Beside, some examples will help you setup your project.

Android Studio vs. Eclipse: Which is Best [duplicate]

This question already has answers here:
Which Android IDE is better - Android Studio or Eclipse? [closed]
(5 answers)
Closed 7 years ago.
Google’s Android Studio is a development tool for Android based on the IntelliJ IDEA platform, one that managed to attract a lot of hype when it rolled out in mid-2013.
Eclipse, on the other hand, is the granddaddy of IDEs. although it support native Android support
which is the main differences in the Android Studio vs Eclipse battle?
which one is best for android devlopment
Go through https://www.airpair.com/android/android-studio-vs-eclipse
This might clerify your doubts.
Contents from site:
1 Before switching to Android Studio
I have written this guide to cover the basics of what you need to know before migrating your Eclipse projects over the Android Studio. If you have a large and gnarly project to migrate from Eclipse over to Android Studio, consider saving time by booking an hour or two with an AirPair expert who has done it before. Otherwise, read on!
2 Say Good-bye To Work Spaces And Sub-Projects
In Eclipse, you are probably familiar with the concept of a "Workspace." You likely even have an Android project currently which includes multiple component projects and libraries which are compiled into ".jar" files and included in the final resulting application. In Android Studio, projects are replaced with a new concept called "Modules" and "Library Modules."
3 Hello Modules
Modules are a "discrete unit of functionality that can be run, tested, and debugged independently" and are somewhat similar to an Eclipse project with a few key differences.
Each Module needs to have it's own Gradle build file(generally automatically generated for you when you create a new one, otherwise you can generate them if you are exporting a project from Eclipse). These Gradle files contain important details such as supported Android version ranges, dependencies and other meta-data about your Android project.
Just like in Eclipse, some Modules may be "Library Modules" which are conceptually the same as "Library projects."
4 Hello Improved Interface Designer
Android Studio features a new and improved interface design perspective where you can view the interface you are working on and its related components.Eclipse also has a similar design perspective so it shouldn't be too big of a shock for you. In Eclipse, a "perspective" is used for providing views and visible actions, as well as delivering mechanisms for interaction with resources, multi-tasking and information filtering.
5 Including Jar Dependencies
Like Eclipse, you will often need to link to JAR files created by 3rd parties. However, you will now need to get used to adding these .jar dependencies to your Gradle build file. Just like Eclipse, you will keep these .jar files in a "libs" folder at the root of your module (e.g. project) directory.
Simply "Right-Click" .jar files in your "libs" directory and select "Add As Library" and your selected JAR files will automatically be added as Gradle dependencies in the relevant build.gradle file for your Module. Make sure to always click "Sync Gradle" to ensure the project has been properly notified of the new dependency on these modules.
6 Adding Module Dependencies
Just like in Eclipse, one Module may depend on another Module. Follow these instructions to establish a dependency between two modules and Android Studio will automatically generate the necessary Gradle entries you will need.
7 Manifest Destiny
One major change you will need to get used to with Android Studio is that several common items and settings which once lived in the Android Manifest now are either automatically added (as in the case of the "debuggable=true" flag indicating an Android application may be debugged) or have been moved to build.gradle such as version codes and API min / max specifications. Feature and permission requirements, however, must still be declared in the Manifest as before (e.g. "permission: camera" and so on).
8 Get Help From An Android Expert
One thing that may be helpful is to enlist the help of a seasoned Android Studio expert to walk you through the nuances of the new IDE. Put in a request on AirPair to get paired with an expert - You will likely be surprised by how much ground you can cover in a short period of time talking to a real person.
9 Migrating From Android Studio
Read my guide on how to migrate from Android Studio to Eclipse to get specifics on the mechanics of exporting and importing an existing Eclipse project over to Android Studio. There are a number of potential issues that can occur along the way which I won't go into extensive detail on here.
10 Gradle Basics
The addition of Gradle is going to be your largest hurdle during your transition over to Android Studio.
11 Unit Testing
Android Studio comes complete with support for JUnit unit and Android tests, read more here. Setting up and running Unit Tests involves creating a few test classes and adding them to your project's run configuration. Follow the linked guide for more specifics. Popular testing frameworks such as Roboguice are not quite supported at this time but it wouldn't surprise me if they are in the near future.
12 Importing Remote Dependencies With Maven
Android Studio allows you to import remote library files from Maven Central. Browse Maven Central for remote libraries you might be interested in and follow these instructions to ensure these dependencies are automatically downloaded at compile time.

How to maintain dependencies located at personal servers with gradle

We are using android studio for android development.
We are using lot of java libraries in our android development.To keep jar files at one place we kept them on our server.
So here is the scenario
We are using java1.jar,java2.jar,java3.jar,java4.jar all of then located on remote server in one folder.
So how to gradle build script which will download all the four jars for us and ads references to our android project.
Can anyone please guide?
Sounds like you want a private Maven or Ivy repo.
The two biggest for Maven are Nexus and Artifactory.

Android studio external library projects

I'm moving from Eclipse to android studio and this is my set up in eclipse:
I have several Android app projects, depending on several library projects (some shared) all within one workspace. In Android studio I first started creating a project per app, but quickly realized that I would have to have the library projects as modules within each project that uses them. This would mean duplicating the library projects and including them in each app, which is highly redundant and would require maintaining multiple copies of the libraries.
So I switched to having all my apps and libraries as modules within the same project. This works for building but creates other problems such as version control issues since each module lives in a separate version control repository.
What is the cleanest way to have this setup? And the real question is, can I have separate projects in AS that share the same external library projects?
NOTE
With the release of Android Studio 0.5.0, this answer is obsolete, but I'll leave it below for reference. For more up-to-date instructions, see How to share a single library source across multiple projects
In Android Studio, it's difficult to have shared library projects, because currently it's a limitation that all modules in a project must live under the same root folder; it seems like you found this out when you tried to solve your problem by making one big project that includes everything. We're working on trying to lift this limitation.
The best answer right now is to make the library modules separate projects and have them publish to a local Maven repository, and have the dependent projects pull them in from that repo. This means that you can't work on your app + library module sources from the context of a single project, unfortunately. A bigger disadvantage is that source attachments for those library modules doesn't work yet, so if you're trying to debug your app, you'll have difficulty stepping into code in the libraries.
I know this isn't a very great answer, but at this stage of Android Studio's evolution, it's probably the best we can do. We know yours is a fairly common use case, and it's a priority for us to support it.

What benefits does Maven give (over ant) for building android projects?

I've recently been trying to setup maven for building my android projects, using the maven-android-plugin.
Whilst this is a good exercise, I'm not convinced that the benefits will outweigh the frustration in getting it working.
Can anyone give me some pros/cons on using Maven for android? I'm not looking for subjective answers, but the facts on whether its worth the effort.
Regards
Well maven is worth it if you are developing a j2ee application to save you from the jar hell
when using external apis
So if you are not going to use the maven repositories its not worth it.
I hate maven because of the problems you already mentioned. But it saves a lot time if you need xy jars. Im currently developing a eclipse plugin which can download required jars and dependencies form maven without the maven compiler or pom files. But its far from ready
You can also create a separate maven project and include it in the android project
im not sure if it works with android but you can do it in standart jdk
Maybe the gradle makes more sense.
Google released an ide called AndroidStudio, it uses gradle. Seems like google will suggest gradle in building an Android project.
I tried to use Maven to build my android project, it's hard to use, finally I changed to gradle.
Another good answer on stackoverflow why-use-gradle-instead-of-ant-or-maven
My android app shares business objects and other functionality with my back-end server so I pulled this out into a common maven project which both the app and the server (as maven projects) have a dependency on. Maven is perfect for this sort of thing, so its helpful in this instance, but if you are writing fairly straightforward apps, I'm not sure what benefit maven would have, especially when getting the android-maven-plugin to behave took me so long.

Categories

Resources