I have a number of projects that I work on simultaneously.
Every time I build and run one of them, the apk is located as usual in the bin folder.
If I want to copy this apk to some other folder outside the project, I have to do it manually.
I created a single batch file that copies all my projects' apk files to the desired location.
Is there a way to change the output location of the bin folder to somewhere outside the project or more preferably run the batch file after each build?
NOTICE
I am using eclipse with ADT. I have tried to add a builder that executes the batch file. However, when the batch file is run, the apk file is not yet generated. I tried all combinations of options in the builder and all the possible of sequences of builders.
If you are happy just to use Eclipse whilst you are perfecting the build, then switching to the command line for the final build, then with Ant it's really easy to get what you want with very little effort or configuration.
Assumptions
1) Your sources are in an Android workspace and you will end up with two sets of binaries - one made by Eclipse, the other made by Ant will end up outside the workspace as set by a PROPERTIES file
2) You are using SDK14 or 15 (Ant changed in 14)
3) You have Ant installed and in your path - you'll need to have Ant 1.8.2 - this is not the internal one that Eclipse uses, you may have to get it from the Apache site, it's easy to install
Steps
1) Make a sample project from the command line as described in http://developer.android.com/guide/developing/projects/projects-cmdline.html
For example I used: android create project --target 8 --name Sample15App --path c:\dev \projects\samples\Sample15 --activity Sample15Activity --package com.me.samplefifteen
This will make a directory and some files which you will use later as a template in your projects
2) Make a sample project in your workspace from Eclipse, I made EclipseSample in one of my workspaces
3) Copy the following files from Sample15App to the root of your EclipseSample project:
build.xml ant.properties local.properties
4) Edit ant.properties (which is initially empty) to be like this example:
projectname=EclipseSample
workspace.dir=/dev/projects/EclipseIndigo/AndroidWorkTwo
base.dir=${workspace.dir}/${projectname}
outbasebase.dir=/dev/projects/AntBuilds
outbase.dir=${outbasebase.dir}/${projectname}
ant.project.name=${projectname}
out.dir=${outbase.dir}/bin
layout.dir=${base.dir}/res/layout
source.dir=${base.dir}/src
From this you can see that my workspace is /dev/projects/EclipseIndigo/AndroidWorkTwo
The eclipse project under this is in directory EclipseSample
I want my apks to end up in /dev/projects/AntBuilds/EclipseSample (i.e outbasebase concatenated with projectname -so for other projects you can use a very similar ant.properties file just change projectname)
5) IMPORTANT - EDIT THE build.xml
Comment out or remove the line :
<project name="Sample15App" default="help">
replace it with just
<project>
This just means it will pick up the project name from ant.properties rather than the build.xml and you can use the same build.xml in all your projects, only ant.properties need change
6) try it with "ant debug" should build the debug apks under /dev/projects/AntBuilds/EclipseSample
7) finally if you want to automate the release build (signing and password entering automatically) add lines like
key.store.password=YourPassword
key.alias.password=YourPassword
key.store=c:/users/you/yourrelease-key.keystore
key.alias=release_alias
to the ant.properties and then you just type "ant release"
If you don't add them it will tell you to sign manually and as no password entries were found in 'build.properties' (- that was what ant.properties used to be called pre SDK 14, they should have corrected this!)
You can add new Builders to your project using Project Properties->Builders->New...
.
One way to do this is to create an ant build (which copies the file), or just a plain old script or batch file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With