I need to create a Maven project for my Android application. When I use the normal Android Maven plugin, it produces a file structure with incorrect location of test classes (the test classes lie where Maven expects them, but eclipse doesn't and it leads to difficulties debugging unit tests in eclipse). There is a workaround for this, but it isn't very elegant.
How can I create a Maven project, which will be compatible with eclipse (allow me to run unit tests in eclipse and - ideally - deploy my application to an emulator from within eclipse) ?
Maybe this project can serve you as inspiration.
Sonatype, one of the main developers of Maven and related projects, has a free chapter about using Maven for Android.
Related
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.
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?
I tried to create an android test project using Robotium as testing framework and maven as builder. But, is it necessary for my android application to use maven as builder ???
No, you do not per se need Maven. As a matter of fact, the Getting Started of Robotium gives a basic example of how to do this in just Eclipse.
Now, would life be better when using Maven. I generally like "yes" for an answer to that question. Testing is only one part of your iterative development, and it is great to have all your steps automated. Doing that with Maven allows you to leverage the entire lifecycle that it offers for your project from test driven development, perhaps in an IDE, to packaging and deployment. And the Android Maven Plugin fits into that approach.
The following options are listed on a maven archetype:generate
19: remote -> android-quickstart (-)
20: remote -> android-release (-)
21: remote -> android-with-test (-)
There is one more plugin available at http://code.google.com/p/maven-android-plugin/
What would be the right archetype / plug-in to use for Android 3.1 application development?
The archetype to use depends on the size and purpose of your project. The different archetypes are similar to creating regular Android projects where:
quickstart creates something similar to an Android application
project but does not create any tests.
with-test is similar to creating an Android application project and a corresponding test project
project release - expands the with-test archetype and also supplies
tools to let maven help out with zipalign, proguard and signing of
your application
For anything relatively complex I would recommend going with the release configuration even though it requires some extra settings since it manages all stages of building, testing and releasing. For prototyping or minor projects the quick-start archetype may be sufficient. With-test can be used if you want to maintain more manual control of the release process but still want a maven managed test project.
If this is the first time you are using the Maven Android plugin I would suggest creating a small experimental project with the quick-start archetype to get the feel for it. Then use a release type project for your application.
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.