Automatic count of compiles in Eclipse/Android development toolkit - android

Im looking for an automated way to update a counter for each time I compile a project. Im going to deploy several test versions of an app and need to keep track of what the testers are referring to.
Im also lazy soo it would be great to find a way of automatically add a build numbering system either by time stamp or by an incremented int.
I could do that in Emacs but for this project Im using Eclipse. Is there a good way of doing it there? I basically want to update a line in the strings.xml with a new value.

You could do all your personal day to day builds using the Eclipse GUI, then use Ant (operating on the same source files but producing output in a defined directory) for the alpha/beta releases. Android tools provides a build.xml which you can modify to include a build number task

Related

Android Build Server for a 1 Programmer "Team"?

Would you recommend the overhead of installing & configuring an Android build server for a 1 programmer project?
The alternative is to upload all sources from development computer to git, download to another computer with Android Studio & Android SDK, and build from Android Studio.
If the answer is yes, would you recommend Jenkins, or another solution?
IMHO, yes, if you have significant time to set it up and maintain it on a separate machine. (I personally would not use a shared machine: too many reasons to restart and disrupt it.)
I feel an extra level of confidence each time I check in if Jenkins builds the whole project successfully from a fresh dir (one less thing I have to do.)
If I forget to check in an important file, Jenkins complains. Or, if I code something that generates a new Lint warning, Jenkins puts a spike in the graph. In other words, on solo projects, Jenkins is like an assistant (or mentor) that helps check my work.
Jenkins can warehouse app installers for future reference. So, it also helps me stay organized.
Jenkins offers some nice communications capabilities too. You can have it automatically notify others via Slack, or put an installer on Dropbox, or, through a service like Zapier, create a custom card in Trello. So Jenkins gives me an outward-facing messenger and delivery service.
These are some plugins I have found useful with Android builds:
Android Lint
Credentials Binding
Environment Injector
Gradle
Slack Notification
ThinBackup
Version Number
Zentimestamp
Of course, this only scratches the surface.
It requires some ongoing maintenance work though. And sometimes it's confusing/challenging to configure. (e.g. some plugins are poorly documented or no longer actively maintained. The linter in Android Studio is not exactly the same as the default one run through gradle by Jenkins, etc)
When I first set my build server up, I had a couple weeks of downtime when I was able to experiment with different plugins and troubleshoot the server. I probably wouldn't have done it without that empty window of time at the start.

Can Gradle use an already compiled Android APK as a dependency?

I'm not too familiar with the Android build process, so I'm sorry if this comes off as a really stupid question.
Anyway, I'm writing testing code utilizing ActivityInstrumentationTestCase2 and Robotium for an Android application by the company I work for.
The company is rather large, so the transition to Gradle is going very slow. I would like to use Gradle for my testing project for ease and future maintainability, but right now the application I'm testing is built using a combination of ANT scripts and manual intervention with all dependencies checked in as jars in the repository. I'm not at all involved in that process, but I know it's pretty hacked together.
From what I understand, Gradle cannot simply depend on and trigger the building of another existing Android project unless that project also utilizes Gradle. So unless I want to really get my hands dirty with the build process of our application (we have people who are literally hired to only deal with that), I'm out of luck.
What I do have access to, however, are debug builds of our application.
So my question is, is there some way that I can have Gradle use the compiled debug APK as a local file dependency, or can APKs not work like that?
APKs don't work like that; you can't depend on them, for a variety of reasons. The most important reason is that the code and resources are processed and compressed and much of the original information needed to build them is lost at that point.
You'll have a tough time getting it to work properly. If things that you depend on are pure Java libraries, then if you could get them in JAR format you could depend on them from a Gradle project pretty easily. But if they're Android projects containing resources and manifest entries and such, then there isn't a compiled file format you could obtain those libraries in that would be compatible with Gradle. Gradle supports the AAR format for Android libraries, but that format is generated by Gradle and nothing else.

Build/Package Android application with rake?

Is it possible to build an android application with rake? The only other question on this subject I saw was a while back and someone advised using Gradle.
So is there any way to do this on the command line, as I am sure under the hood eclipse just runs a lot of command line guff to get the apk file generated then spits it to the device, I just want to generate the apk file (there is alot of other things to be done but these are prior to the APK building).
Is it possible to build an android application with rake?
Yes, insofar as it is possible to build an Android application using Ant, and rake can in theory do everything Ant can.
If you are expecting to find an existing rake script, though, you will likely be disappointed. The Ant scripts necessary to build an Android app are rather substantial, and porting all of that to rake will take quite some time. And, then, they will perpetually be out of date, as those Ant scripts are often modified with Android tools releases.
Here's a small example project that's worth a look: https://github.com/jberkel/android-helloworld-rake
I've been meaning to try it out myself.

Why we use build.xml in android?

I am android developer.I am not aware of ant in android .I have downloaded a code from internet But It has file called build.xml but I am not able to find out what it is doing and for what purpose it is used please give some advise or some kind of tutorial.So I can understand its working thanks in advance.
When you are developing your application, Eclipse is the most convenient way of building the project.
However Ant is most useful when you come to produce a release version. You can set up your Ant build, such that it takes the same source files as the Eclipse project, yet produces a signed, zip-aligned version of the apk in completely separate output location.
By means of a custom build.properties file you can specify source and output locations, keystore names and locations and passwords. It also takes care of any Proguard obfuscation you may want.You can do all this from the command line with a single statement and know that you are going through a repeatable process, not vulnerable to a mouse click in the wrong place.
Have a look at Managing Projects from the Command Line and Building and Running from the Command Line
Take the build.xml from the sample project referred to and use it as a basis for your own project. It works pretty much out of the box.
This build file is an alternative (and less common) way to build your projects using ant.
Eclipse (and the Android plugins) do a n excellent job of saving you the trouble - just use the plugin to build your projects and export APKs.

Ant versus Eclipse builds for Android: Strengths of Each?

I've used Eclipse and vim variously as development environments for Android applications and found both the Eclipse plugin and the command-line SDK tools to be of similar capability.
Since I haven't explored either in its entirety, however, I'd like to ask:
What advantages are there to using Eclipse over the command-line tools and vice-versa?
I could see:
(Eclipse) nice GUI for debugging
(ant/adb/android) more amenable to automation
(hybrid) you can have it all, can't you!?
I'm especially interested in specific features that may be a deal-breaker for one and move a developer in the direction of the other.
Using Eclipse as a development environment for Android doesn't preclude you from also building with Ant to hook into nightly builds or CI tools. You could even configure Eclipse to build using your Ant buildfile if you wanted. If you want some kind of CLI build tool, you might also consider Maven, as it also has plugins to enable building Android apps.
It has been some time (like six months) since I have used eclipse, so maybe it is better now, but I gave up on it because I found it to be very slow and buggy. Maybe it is the integration with ADT, but several times I spent hours hunting down problems that turned out to be fixed if I killed and restarted eclipse (and these problems were not fixed if I did a "clean" within eclipse). After doing that a few times, I felt like throwing the computer against the wall.
"ant clean" is much easier and faster than stopping and restarting eclipse.
Across my personal projects and multiple professional instances of building Android apps, I've always used both types of builds. You'll want to use Ant (or Maven, if you prefer) to set up continuous integration and automated testing. Trying to get that working with Eclipse (which I did a long time ago when the Android SDKs were first coming out) is a nightmare, while Ant/Maven is easily used from any of your favorite CI tools (I've usually used Hudson for this). If there's nothing unusual about your project, it'll be a snap to put together continuous integration, and off you go.
Meanwhile, for just day to day development work, using Eclipse to build your app locally works just fine. But that can easily be left up to the individual developer. I'd make the build that your CI system is running the canonical build, but I do use Eclipse for my normal development.
I'd use Eclipse until such time as you are happy with the debug build. Then you can set up Ant to produce the signed release build.
You can set it up to use the same source files as Eclipse but put the output binaries outside your workspace. You can also set it to use your release.keystore, sign it automatically and obfuscate the code all in one go.
I've set it up to do this. I open a command line (DOS box) move to the projects home directory (\dev\projects\Eclipse\Project1 say), I type "Ant release" and the apk ends up in \dev\projects\AntBuilds\Project1\bin as Project1-release.apk.
If you want the best of both worlds, you might want to look at the m2eclipse-android-integration Eclipse plug-in which allows you to use your command-line Maven build in the ADT/Eclipse environment as well:
https://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/
Well for me im just a beginner, but I find eclipse much easier to work with. Android is a pretty complicated to get used to (for me) so having everything layed out in a GUI is preferable to command line. Plus SDK updates and such are easier to get.

Categories

Resources