I’ve been trying to understand the Android build process for several hours now.
I am using IntelliJ Idea for Android (this is a great tool). I opened a test project called IntelliJ "Hello Android". The project has this build.xml file name, the code below
<?xml version="1.0" encoding="UTF-8"?> <project name="HelloAndroid" default="help"> <property file="local.properties" /> <property file="ant.properties" /> <property environment="env" /> <condition property="sdk.dir" value="${env.ANDROID_HOME}"> <isset property="env.ANDROID_HOME" /> </condition> <loadproperties srcFile="project.properties" /> <fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." unless="sdk.dir" /> <import file="custom_rules.xml" optional="true" /> <import file="${sdk.dir}/tools/ant/build.xml" /> </project>
Then I did the following in IntelliJ Idea Build -> Generate Ant Build and selected the following options
- Creating a file with multiple Ant build files
- Output File Name: helloandroid
- Enabling compilation of user interface forms
- Use JSDK definitions from project files.
This led to the creation of three additional files
- helloandroid.properties
- helloandroid.xml
- module_helloandroid.xml
helloandroid.properties
path.variable.maven_repository=C\:\\Users\\abc\\.m2\\repository jdk.home.android_4.1_platform=C\:/Program Files (x86)/Android/android-sdk
helloandroid.xml
<?xml version="1.0" encoding="UTF-8"?> <project name="HelloAndroid" default="help"> <property file="local.properties" /> <property file="ant.properties" /> <property environment="env" /> <condition property="sdk.dir" value="${env.ANDROID_HOME}"> <isset property="env.ANDROID_HOME" /> </condition> <loadproperties srcFile="project.properties" /> <fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." unless="sdk.dir" /> <import file="custom_rules.xml" optional="true" /> <import file="${sdk.dir}/tools/ant/build.xml" /> </project>
module_helloandroid.xml
<copy todir="${helloandroid.output.dir}"> <fileset dir="${module.helloandroid.basedir}/src"> <patternset refid="compiler.resources"/> <type type="file"/> <patternset refid="excluded.from.compilation.helloandroid"/> </fileset> <fileset dir="${module.helloandroid.basedir}/gen"> <patternset refid="compiler.resources"/> <type type="file"/> <patternset refid="excluded.from.compilation.helloandroid"/> </fileset> </copy>
My question
- Why do we have different build.xml and helloandroid.xml files and two other files?
- Can these files be used during the build process?
- Can we edit these files to add another Ant build script?
- Why is build.xml showing an error in
env.ANDROID_HOME ? - What does helloandroid.xml show an error in
jdk.home.1.6 ?
source share