Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:10:35+00:00 2026-06-16T02:10:35+00:00

I am trying to compile an Android project using Ant so that it works

  • 0

I am trying to compile an Android project using Ant so that it works with a build machine and I am having issues. I have five projects total: three are just java library projects and the other two are actual Android projects. Only one project is actually compiled and installed but it pulls from the other projects in order to compile.

I have tried using the android update project --name <name> --target <target> --path <path> to generate my build.xml file. It generates the build.xml just fine but when I go to run it, it can’t correctly include my other projects as dependencies.

I then tried to export the build.xml file using Eclipse and that will correctly include the dependencies but it won’t generate my R.java files.

I would prefer the second approach because Eclipse has already taken care of my dependency settings, but is there something I can add to the build.xml file that will generate my R.java file correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:10:38+00:00Added an answer on June 16, 2026 at 2:10 am

    I ended up figuring this out. What I ended up doing is use the Eclipse export tool to export an ant build script for the three Java library projects. I then created a file called build-custom.xml which contains additional targets for copying the jars.

    Next, I used the android update lib-project command on the Android library project to generate the build.xml for that project (as specified in http://developer.android.com/tools/projects/projects-cmdline.html). In order to include the Java library projects in the build, you have to copy them to the libs folder in the Android project. So I created a build file called custom_rules.xml in the Android library project that copys the jars into the lib folder. IMPORTANT: Also write a rule that removes the jars when done otherwise you will get Davlik Error 1 when you try and run in Eclipse.

    You may or may not have an Android library project but the steps are pretty much the same for the main project as the library project. Just use the android update project command and then create a custom_rules.xml to copy the appropriate jars.

    Edit:

    After I used Eclipse to generate the build scripts for the basic Java library projects, I created a common.xml ant build file. This file basically looks like this:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <project name="common">     
        <target name="clean">
            <delete dir="build/libs" />
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary1" target="clean" />
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary1" target="cleanup-jars" />
                <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary2" target="clean" />
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary2" target="cleanup-jars" />
                <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary3" target="clean" />
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary3" target="cleanup-jars" />
                <ant antfile="build.xml" dir="./AndroidSubProject" target="clean" />
        </target>
    
        <target name="samplesublibrary1">
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary1" target="all" />
        </target>
    
        <target name="samplesublibrary2">
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary2"     target="all" />
        </target>
    
        <target name="samplesublibrary3" depends="samplesublibrary2">
            <ant antfile="build.xml" dir="./SubJavaLibrary/SampleSubLibrary3" target="all" />
        </target>
    
        <target name="android-sub-project-copy-jars" depends="samplesublibrary1, samplesublibrary2, samplesublibrary3">
            <ant antfile="build.xml" dir="./AndroidSubProject" target="android-project-copy-jars" />
        </target>
    
        <target name="android-sub-project-debug" depends="android-project-copy-jars">
            <ant antfile="build.xml" dir="./AndroidSubProject" target="debug" />
        </target>
    
        <target name="android-sub-project-release" depends="android-project-copy-jars">
            <ant antfile="build.xml" dir="./AndroidSubProject" target="release" />
        </target>
    
        <target name="android-sub-project-remove-jars">
            <ant antfile="build.xml" dir="./AndroidSubProject" target="android-project-remove-jars" />
        </target>
    </project>
    

    Then in the Android-Sub-Project, I added a custom_rules.xml file that contained the following:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <?eclipse.ant.import?>
    <project default="android-project-copy-jars" name="Copy required jars to lib folder">
      <target name="android-project-copy-jars">
        <copy file="../../build/libs/SampleSubLibrary1.jar" todir="libs"/>
        <copy file="../../build/libs/SampleSubLibrary2.jar" todir="libs"/>
        <copy file="../../build/libs/SampleSubLibrary3.jar" todir="libs"/>
      </target>
      <target name="android-project-remove-jars">
        <delete file="./libs/SampleSubLibrary1.jar" />
        <delete file="./libs/SampleSubLibrary2.jar" />
        <delete file="./libs/SampleSubLibrary3.jar" />
      </target>
    </project>
    

    I then created a main build.xml in the project root that includes and runs all the other sub build.xml files:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <project basedir="." default="all">
        <target name="debug" depends="clean, main-debug, android-project-remove-jars" />
        <target name="release" depends="clean, main-release, android-project-remove-jars" />
    
        <import file="common.xml" />
    
        <target name="clean" depends="common.clean">
            <ant antfile="build.xml" dir="./Main" target="clean" />
        </target>
    
        <target name="main-debug" depends="android-sub-project-debug">
            <ant antfile="build.xml" dir="./Main" target="debug" />
            <copy file="./Main/bin/main-debug.apk" todir="./build/bin" />
        </target>
    
        <target name="main-release" depends="android-sub-project-release">
            <ant antfile="build.xml" dir="./Main" target="release" />
            <copy file="./Main/bin/main-release-unsigned.apk" todir="./build/bin" />
        </target>
    </project>
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile a project using appcelerator (crossplatform dev for iphone/android). Just evaluating
I'm trying to use sbt to compile an Android Project made in Java, which
While trying to compile my project, that uses some third party headers, with mingw
I'm trying to use the Google Maps API v2 in an android project that
I am loosing my mind trying to build my NDK project from eclipse using
I am trying to cross-compile a very simple program for Android that worked with
I have an Android project developed on Eclipse (GNU/Linux) that I last touched half
I'm running Ubuntu Linux, and trying to compile native code for Android using the
I am trying to compile a java project which makes uses of android libraries.
I am trying to do some stuff before a build of my Android project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.