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.
Related
My ultimate goal is to be able to write Clojure apps for Android, using Android Studio and Cursive. I started with leiningen but found out that it is a build system that is independent of what Andoid Studio uses ie Gradle. So I tried leiningen with Intellij, but couldn't get Android deploys to work except from the command line. Since I wanted to integrate with Android Studio, I decided to try Graclj: https://github.com/graclj/graclj which is a Gradle plugin for Clojure.
I can get the Graclj tutorial running in Android Studio, as per this guide:
https://github.com/graclj/learning-graclj/tree/learning-0.1.0
However:
Graclj expects the Clojure src and built classes and jars to be in the root project
Android Studio expects src and classes to be in the app subproject
After the tutorial I end up with separate Gradle build tasks for Graclj and Android Studio but I don't know how to integrate them
So, can anyone suggest a way that I can hook into Andoid Studio's build process?
Do I need to change some settings to the Graclj plugin to do this? If so, how?
Do I need to change some Android Studio plugin settings?
Do I need to add/change something in the Gradle build scripts?
Am I heading down a dead end? ;-)
I have looked at the Android Studio build process: http://developer.android.com/tools/building/configuring-gradle.html
but I don't know enough about Gradle to know what I'm supposed to be doing here.
If I need to supply any more info, just ask.
Any help appreciated!
Unfortuantely, I don't have any Android (let alone Android Studio) experience. However, I'll do my best to answer based on Gradle/Graclj knowledge.
Graclj does not require you to use the root project. You can apply the plugin(s) in any of the projects that you have in your build. However, I don't know how well a model-based plugin like Graclj will work with the "traditional" Android plugin. You could try the "experimental" one that's using the model approach, though there's a decent chance that it won't be compatible unless there's one that works with Gradle 2.12.
Alternatively, you might be able to add a dependency to the Android app project on the JAR produced by Graclj (which you may still want to put in a project besides the root). Not sure if there's a very good way to do this (haven't tried myself).
dependencies {
// my-other-proj being whichever one you use Graclj in
compile project(':my-other-proj')
}
Or maybe you would need to add it to a configuration first in the my-other-proj to interop with traditional plugins:
artifacts {
archives createMainJar
}
It is possible that you're at a dead end (for now). Graclj is very new, so this stuff should all be possible eventually.
I have a utility library, that I'd like to use in several app projects.
I'd like to be able to work on it without having to deploy to a server every time I change something. I need a way to test it in my app before publishing the changes anywhere.
The way I would normally do this is to install the lib to my local maven repository (by local I mean on my dev machine's hard drive), in order to make it visible to the app projects.
Unfortunately, it seems that gradle install doesn't work on Android projects (see this SO question).
So my question is, what's the recommended way to do this and how do most people do? This seems to me as a fairly common use case!
I describe my current workflow. Maybe it helps you, too.
If I develop a library, which targets a special app, I upload a Snapshot build to my local maven repo (upload works). In my app project I reference the Snapshot build. Each time you build the app project Gradle checks for a new Snapshot release. So you definitely use the most current version of your library.
If the library is finished, I upload a finished (no Snapshot) build with a fixed version to my local repository. Later, if I want to extend the library, I increase the version of the library and add the snapshot suffix again.
I'm pretty happy with this workflow. You may want to take a look at one of my build files. In order to upload a Snapshot build, you only need to add the suffix '-SNAPSHOT' to the version string.
If you are already deploying to the maven local, then you can just add that as a repo source for gradle. At least that's what we did:
repositories {
mavenLocal()
}
I am extremely new to the idea of Build Automation, and am not sure if it would be helpful for me or not. Honestly, I'm not exactly sure what it does or the benefits of it. I've been looking up a lot of information about Maven, and am having a bit of trouble piecing it all together.
Right now I develop a lot of similar Android applications. Most of these applications have a similar base of functionality which I copy from one application to the next. However, when I make changes to one part of that "main functionality," I need to go back and apply the changes to other applications. This is horribly inefficient, obviously. What I've been beginning to do is to set the main functionality as a library which is then imported by each application. So far so good.
So in addition to the library approach I'm using, would Maven be helpful? Is there something else more helpful that I haven't seen yet? Sorry for the really basic questions and thanks for the help!
Maven will not help you for code generation it will only help you to automate your build process.
You can configure your eclipse using maven plugin for android Android SDK Full Javdocs with Maven in Eclipse
I have not used Maven for android project as of now since currently I am using Ant for that purpose. You will find sample maven and ant files in the examples in android SDK
About code Generation:
I have read that Acceleo provides support for android based UML Code generations.
I've started work on an Android App that will work with Google Docs.
UPDATE 12/9: From the information I've come across, it seems Google Docs is not supported by this library. The question is probably still relevant in general, but seem not specifically for this project as I can't use the library anyway.
I was doing some research and come across the Google APIs Client Library for Java
I decided to start with the tasks-android-sample to begin learning how to utilize this library.
I followed these instructions
I successfully installed Mercurial and Maven and already had Java 7 installed.
I was able to execute these commands
cd [someDirectory]
hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
cd google-api-java-client-samples/shared/shared-sample-android
[editor] src/main/java/com/google/api/services/samples/shared/android/ClientCredentials.java
mvn source:jar install
I was also successful in setting up the Mercurial plugin (not sure what this did for me -- I believe the hg command above is the only time Mercurial was involved) and Maven plugin
Finally, I was able to imported the tasks-android-sample, compile it, run it on the emulator and I was able to see the tasks I created on my google account.
I then repeated the process, except this time I simply imported sample's source code and the required JARs into a new Android project and added the ClientCredentials.java manually to the project (So I could specify my Google API Key).
I was also able to compile and run this project and it operated as expected.
My questions in all this is which method is preferred? Or is it a personal choice? Are there benefits to using Maven that I'm not realizing at this time?
Maven helps you download proper dependency libraries for the project, and can reduce the burden of find and download proper libraries.
It's fine to just put dependency libs in your code base. It's a personal choice.
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.