Upgrading Ant in Eclipse Juno - android

I am trying to run a test and get coverage for an Android application I developed, and because this is for research purposes, I would also like to be able get coverage for the Android source code being call as well as coverage for my application under test. I followed some advice on another question I asked and am currently trying to use Ant.
I ran
ant emma debug install test
in my test but it gave me the following error:
BUILD FAILED
/scratch/android-sdk-linux/tools/ant/build.xml:377: The Android Ant-based build
system requires Ant 1.8.0 or later. Current version is 1.7.1
I went online and installed the latest version of Ant directly from the Apache website, but now I've realized that I need to upgrade the version of Ant in the SDK directory. I haven't just simply copy and pasted because I had a feeling that would mess up with the paths in the configuration that are probably called when commands such as above are called.
What I want to know is if there is a way to update specifically the version of Ant contained in the Android SDK?
Thanks.
EDIT: I tried changing the Ant classpath in Eclipse Juno to where I stored a version of Ant 1.8.4. However, I still get the error that the current version 1.7.1. At this point, I'm sure that I need to probably change settings somewhere in Eclipse for this to work, but how?

I am not sure, if we just use different SDKs, but my android SDK doesn't contain any ant itself :)
Just some ant build files, but the normal ant installed is used. So I would assume, that you did something wrong, with upgrading ant. If you enter in your console ant -v it should print out the version. As long as this version isn't larger or equal than 1.8.0, something with the upgrade has gone wrong.

Related

Is the platform required to compile and build Android apk

I have set up a Concourse CI pipeline to run tests and build my apk. I've built a docker image for my job to run in. The image contains the sdk tools, build tools and platform tools but does not contain the platform that corresponds to the compileSdkVersion. It seems to work and build the apk correctly, I can run the apk on a device. I'm slightly confused by this as I would have thought that the platform would be required. Does anybody know how this is working under the hood and what the minimum set of files are required to compile and build the apk?
Thanks
It turns out that gradle actually pulls down the platform during the build, I noticed it in the logs.

What's the proper way to upgrade gradle in Android Studio?

Most resources online say that you update gradle by simply updating the distribution URL. This is the answer all over Stack Overflow and all over.
Codepath also just says that a url update is enough: https://guides.codepath.com/android/Getting-Started-with-Gradle#upgrading-gradle
I've seen scattered throughout a couple of answers that to upgrade gradle you need to run a gradle update script from the command line ./gradlew wrapper --gradle-version x.x.x.
I haven't been able to find documentation that says "This is how you update gradle". On gradles website you can see, "This is how you add the gradle wrapper". I guess I'm not sure what is enough, and I feel like a lot of people are doing it the wrong way, and maybe are not benefiting from performance and speed increases in gradle.
Any canonical answer on this? Someone from the tools team want to comment?
If your project is using the Gradle wrapper then Android Studio will automatically use it. The correct way to upgrade Gradle (via the wrapper) is to run
$ ./gradlew wrapper --gradle-version x.x.x --distribution-type all
The --distribution-type option is supported since Gradle 3.1 and allows to use the all distribution instead of the default bin distribution to get proper IDE support for Gradle build files.
If you are unsure what the latest version x.x.x is, or you are setting up a project from scratch, you might be interested in my gradle_bootstrap.sh helper script which is able to install / update the Gradle wrapper without having Gradle installed. Use it like:
$ gradle_bootstrap.sh all
Just updating the Gradle distribution URL in gradle-wrapper.properties as described in the official docs is not enough in cases where gradle-wrapper.jar itself got updated.
Finally, if you do not use the wrapper yet, Android Studio will prompt to "Click 'OK' to use the Gradle wrapper, or 'Cancel' to manually set the path of a local Gradle distribution", where the latter can point to the Gradle version that ships as part of its installation. At the example of Android Studio 2.2.3 that would be Gradle 2.14.1, which is a bit dated.

Build (not develop) your android app .apk (gradle build) on server?

I'm trying to build(not develop) an android application on server. I've the whole native android code on the server, which I need to build according to some modification done on the server.
I've been looking all over the internet but couldn't find any detailed solution. All I got to know was I might need Jenkins or some CI tool (which I think is time consuming as I'll need to get them installed on server and then all the android dependencies).
Initial idea was to build the .apk file via some python script which contains all the gradle commands in it.
How can i do this?
Android apps can be built easily on a system that doesn't have any Android tools installed by applying the Android SDK Manager plugin for Gradle to your project.
When running ./gradlew assembleDebug (or whatever task), then Gradle will be installed and then all Android dependencies, including the SDK tools, build tools, platform versions and other dependencies will be installed automatically.
You can run this simply on the command line yourself, or automate to run after every commits to source control easily with Jenkins (it's easy to install on a wide range of operating systems).
You need to install Stand-alone SDK tools and suitable SDK packages to your server to build Android software.
When you have all installed and good, you can build APK with gradle , e.g.
(Linux and Mac)
./gradlew assemble

Compile Android project in Continuous Integration System Hudson?

I'm setting up a Continuous Integrations System with Hudson and it's just amazing.
I got a SVN repository and integrated a post-commit hook that notifies Hudson when someone commits to the repository. This part is working splendid.
The general idea is, that if the project fails, with unit-tests or anything else, it should tell the collaborator(i'm using a simple e-mail notifier atm). But if it successes I want it to compile the project and build either an unsigned or a signed .apk file.
What's the easiest or smartest way to do this?
I've read you can use a Shell Command to build the .apk but I can't seem to figure out how this works? Can anyone tell me how I can do this or should I go for another solution?
Thanks in advance
Finn Larsen
There is a guide on the Jenkins wiki about building Android apps with Hudson or Jenkins, including building and running a test app, obtaining code coverage and static analysis stats.
Essentially you can use the Ant support built-in to build your application.
If you want to run automated tests, you can also use the Android Emulator Plugin.
Since you're just starting out with Hudson, I would say now is a good time to upgrade to Jenkins. ;)
As far as I remeber hudson supports ant's builds. And android apps can be built using ant use this link for more info about building android apps with ant. Be aware that you'll have to install Android SDK on your build agent.
Android provides ant build script. So, you can make apk easily.
install android-sdk in hudson server
install ant in hudson server ( ant version should be > 1.8 )
in hudson, call cmd android update project -p <PATH to your project>
in hudson, call ant debug. debug target generates debug apk build

Builds of Android package fail with 'apply' message after updating SDK - how to fix?

I recently upgraded the Android SDK on our build machine, and now Android builds using Ant fail with the obscure message:
The <apply> type doesn't support the nested "path" element.
Our build.xml is the standard one generated by Android tools, and we automatically run
android update project -p .
before Ant runs the debug task.
The error message appears during the -dex phase of the build process.
Since this buildfile is using one of the standard Android templates, I'm not sure what's causing this change in behavior. Any ideas?
Never mind, I figured it out. Seems that Android version 8 or higher now require you to have ant 1.8 or higher (I was still using 1.6.5). The fix was simply to upgrade my ant installation to the latest version.

Categories

Resources