For the past 3 weeks I've played heavily with Android Maven build process. For the most part I find it a much better experience than Eclipse but have a few questions I'd like answered:
Is there a way to make Eclipse work with APKLIB files without importing the project into Eclipse?
Using Maven is there a way to push the APK to the device without uninstalling the application? Using mvn android:deploy uninstalls the APK and installs a new one.
I've yet to get the Android JavaDoc to work well in IntelliJ, any solutions?
Does IntelliJ work well with the NDK?
I'm open to any tips in the best build process for the platform as it will be what I use moving forward. Should I go Ant or Maven?
APKLIB support in Eclipse is still not fully there. Use m2eclipse and m2eandroid and maybe help with patches for m2eandroid.
mvn android:deploy can install an apk to the device (or all attached devices). mvn android:run can start it. undeploy and redeploy work as well.
the maven android sdk deployer can also deploy the source and it should hook up fine with intellij and the maven integration
NDK and Intellij - not for writing code but the build process via Maven will work just fine also in Intellij..
Last but not least.. you should definitely NOT go ant. Either Maven or use the new, upcoming Gradle build. Don't waste time on the old (and soon to be deprecated) Ant build and all its problems.
Related
I'm a devops engineer, and my company is building their first Android app. For all of our other projects, we've used Jenkins to handle builds.
I've read quite a few tutorials on getting android building on Jenkins and they all seem to rely on Gradle. I'd like to get out in front of the devs a bit and start the job. Is it possible that the app that they build doesn't support Gradle? What scenarios are those, so I can influence decisions?
Maybe Gradle isn't the latest thing, if not, what is?
Is it possible that the app that they build doesn't support Gradle?
It is possible that they are not currently building the app with Gradle, but highly unlikely that the app could not be built with Gradle.
What scenarios are those, so I can influence decisions?
The most likely scenario where they are not building with Gradle, is that they use the Eclipse IDE to develop the app. Eclipse projects have historically been built more often with Ant or Maven. But an Eclipse project can be built with Gradle. That said, configuring an Android project to be built with Gradle is not a requirement to build that project with Jenkins. Ant, Maven, and other build tools play nice with Jenkins also. So, if your dev team is using a build tool other than Gradle, that shouldn't be a blocker for you. You should be able to accommodate them, if that's going to cause less friction.
Maybe Gradle isn't the latest thing, if not, what is?
I'm not sure about latest, but Gradle does currently have a lot of momentum as the build tool of choice for Android projects because it is the default build tool for Android Studio (which is positioned to replace Eclipse as the default Android IDE).
So, my advice would be to ask your dev team what IDE and build tool they are currently using, and go from there... (if they use Eclipse and you want to build with Gradle: Is it possible to use the Gradle build system for Android with Eclipse?)
Source: At the company I work for, I develop two Android apps and make daily builds with Jenkins. A few months ago I switched from Eclipse (Ant) to Android Studio (Gradle).
I hope this was helpful. I have not answered many questions on here so I'm not entirely sure I'm doing it right. :)
I'm building an Android project in Jenkins. Everything was fine until upgrading to the lastest plugin version, but now it fails with "requires Maven version 3.1.1". Fair enough, but Jenkins seems to be stuck on Maven 3.0.4, even though I'm using the latest version (currently 1.553) of Jenkins and all its plugins. How to I make it update to a more current release of Maven?
Building in Jenkins via android-maven-plugin, which as of version 3.8.0 requires Maven 3.1.1 or higher (see http://code.google.com/p/maven-android-plugin/wiki/Changelog). Of course it can be done manually, outside Jenkins. The question is how to get Jenkins to use a current Maven; it seems to come packaged with an older one, and I'm not familiar enough with it to see where/how to update.
Update: For anyone following my footsteps, note that upgrading Maven will break the Android build until android-maven-plugin is also updated; they go together.
Jenkins does not come with Maven, but it can install it for you.
To Update Maven version used by Jenkins
Goto Manage Jenkins -> Configure System.
Scroll down till you see Maven section (not Maven Configuration or Maven Project, those are different).
Click Add Maven button.
Leave Name as default.
Checkmark Install Automatically.
Install from Apache is the default installer option.
Select the version you want installed.
Besides "Install from Apache", you can also install it from a zip or by executing a command line. Just delete the apache installer and click Add Installer button to select another option.
I would suggest to run a dummy Maven project at least once to verify this gets installed.
Jenkins doesn't come with maven as far as I am aware of. You can specify a maven installation in the Jenkins settings. I usually use a reference to a symlink (debian) and let that symlink point to my "current" or preferred Maven version.
You can alternatively install a recent maven version via Jenkins in the Jenkins settings aswell. And on my Jenkins there is a 3.1.1 via apache available.
I want to work with Maven dependencies in an IntelliJ Android project. Has anybody successfully done this?
I use IntelliJ IDEA (currently v11.0.2, build 111.277) on both Ubuntu 11.10 and Mac OS X 10.7.3 for working on Maven-based Android projects, and for the most part it works well. A nice thing about using IntelliJ with Android and Maven is that all support is already built-in - there are no extra IDE plugins to install.
As an example of a good working Android Maven project that can be opened with IntelliJ, you could use the source code of the open-source Gaug.es for Android app by GitHub (not all developers at GitHub use IntelliJ, personally I do - Eclipse is also used to work on this project).
The first step for smooth running is obviously to ensure that your project builds correctly using only plain Maven at the command line - although the question doesn't directly ask about this, I'd advise these pre-requisites as a bare minimum:
Java 6
Maven v3.0.3
android-maven-plugin v3.1.1
Android SDK r16 (if you downloaded your SDK before r15, you're probably better off nuking the entire thing and downloading it all again, as the directory layout has changed)
If you can mvn install the parent pom of your project, you're good to move on to actually working with it with IntelliJ.
If this is the first time opening the project with IntelliJ, you can still open it as a project, you just need to select the parent pom.xml file in the 'Open Project' dialog.
Ensure IntelliJ knows where the Java SDK is. IntelliJ, even though it's running on Java, doesn't auto-detect the location of the SDKs. You have to tell it. Go Project Structure, Platform Settings, SDKs and then edit the Java SDK if it's showing as red, giving it the path of your Java 6 SDK.
In the same Project Structure dialog window, set the Project SDK to the appropriate Android version, and under Project set the Project compiler output to whatever directory name you like - this value is required for doing a 'Make', but also overridden to by your submodules to sensiibly point to the Maven 'target' directories.
Double-check that all the Maven information has been parsed by IntelliJ. You should have a Maven Projects tab. Hit the Reimport All Maven Projects button (looks like two arrows chasing each other). If IntelliJ prompts you to enable Auto-Import, go for it. You should now have at least one module listed under the Maven Projects tab, more if you have an integration test project as well.
At this point, you should have a fairly meaningful IDE experience. Stuff that should work:
There should be no code underlined in red for no readily apparent reason.
All imports (whether from the Android SDK, Java, your own code or from apklibs) should be recognised. Note that apklib support only came in with late IntelliJ IDEA v10.5.
Refactor operations.
Force regenerate R.java file should correctly refresh the file under target/generated-sources/r/... - but this only seems to work if target/generated-sources/r is already set as a source path, ie has been generated by Maven, and imported by IntelliJ. The minimal command line alternative is to execute mvn android:generate-sources from the command line in the folder of the affected module.
Doing a 'Make' of the project within the IDE technically works, but again might fail for the same reason. I invoke all my builds using the mvn package or install at the command line.
Stuff that might not work:
Running individual integration tests from the IDE (dies with ClassNotFoundException: junit.textui.ResultPrinter)
If IntelliJ gets confused, the following steps will normally get you back on track:
mvn clean install on the command line
Hit the Reimport All Maven Projects button
Some advice:
Your Maven pom.xml files should be the source of truth for your project configuration. Minimise IntelliJ-specific configuration you do in the project settings- some of it will be liable to get wiped the next time settings are re-imported from the Maven POM - and try to avoid committing IntelliJ project files into source-control.
Hope that helps!
See Getting Started with the maven-android-plugin.
Here the command you can use to create an sampe working template with Maven structure:
mvn archetype:generate \
-DarchetypeArtifactId=android-with-test \
-DarchetypeGroupId=de.akquinet.android.archetypes \
-DarchetypeVersion=1.1.0 \
-DgroupId=com.foo.bar \
-DartifactId=my-android-project \
-Dpackage=com.foo.bar.android
BTW, IntelliJ has built in support for maven, so just open pom.xml from it - and everything will be ok.
Am trying to copy sources from a maven multi-module web project to a maven-android project. This needs to be done as the sources (which I want to keep outside of the android project for another platform) need to be compiled under Dalvik in order to be run on android. Aside from that, dependencies are not packaged when running on android, but the need for compiling using Dalvik overshadows this limitation.
The closest documentation of the issue I found here.
Am using mvn dependency:unpack to unpack the sources to the android project in eclipse. Prior to this I need to run mvn install to install the sources to the local repository. Then I have to refresh the eclipse android project.
The ideally scenario would be for this to work directly with m2eclipse without the three step manual process.
Would appreciate any inputs.
Thanks
sfk
I would suggest lifting the common sources out of the web-project into their own project.
The new project should be configured to produce two artifacts:
normal jar file : for inclusion in the multi-module web app
apkLib : for inclusion in your android projects
This could be done by defining a secondary attached artifact with in the maven naming co-ordinates (groupId:artifactId:packaging:classifier:version).
see http://code.google.com/p/maven-android-plugin/wiki/ApkLib
I am trying to use android in netbeans with maven as the build tool. I want to be able to run the applications in netbeans and also run the emulator in netbeans itself. So far i have been using the command line for creating android applications with maven. Any help will be appreciated
thanks in advance
Abhirami
Technically it is possible with stock distribution of NetBeans IDE. Everything Android related will be handled by Maven there (including compilation against correct platform and special goals to deploy).
You will miss some goodies provided NBAndroid for regular Android projects. Some of them are available as you can read at http://www.nbandroid.org/2012/06/did-you-ask-for-maven.html.
are you looking to integrate maven with eclipse?
It's pretty simple. You Just have to follow the instructions here.
for NetBeans -
"NetBeans includes full Maven support since 6.7, including Maven 3 support in 7.0+. You can open any Maven project in the IDE and start coding immediately." as quoted here