20

I'm adding an android library project to my android app (in this case, Beintoo). It's not mine; It's an external library. However, it doesn't come with a build.xml. Building in Eclipse works fine, but when I attempt to build my app with ant, I get this:

BUILD FAILED
C:\Sandbox\MyProject\build.xml:110: The following error occurred while executing this line:
C:\Sandbox\MyProject\build.xml:41: The following error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:515: Invalid file: C:\Git\Beintoo-Android\beintoo-android-sdk\BeintooSDK\build.xml

It's perfectly true. The file is invalid, because it doesn't exist. I wouldn't know what to do to add it safely, nor if that's even a good idea.

I have learnt that I can't simply build the library project into a jar. How can I get my project to build in Ant with this library project?

3 Answers 3

32

Ok, so, Error 454's answer was close, but not quite right. Since r14 of Android Tools, every library project must have it's own build.xml if it is to be built by Ant, as noted here:

https://groups.google.com/forum/?fromgroups#!topic/adt-dev/Z2e3dY-3Ma0

Running android update lib-project (which, as Error 454 notes, is in the android-sdk/tools folder which should be in PATH) on the library project will add a generic build.xml, and allow the main project to build.

1
  • 3
    Great answer! More specifically I had to run "android update lib-project -p ." from within the library project. This generates build.xml and proguard-project.txt.
    – runamok
    Nov 5, 2013 at 21:14
19

For library projects, you need to browse to the library project root and run:

android update lib-project -p .

The android executable is in the android sdk/tools folder which should be added to your path variable in your OS. Once you run this, the necessary build files will be generated and your ant build should succeed.

Similarly, if your root project doesn't have the necessary build files, you will need to browse to the main project root and run:

android update project -p .
1
  • I discovered and ran "android update lib-project" on the library project, which seemed to help, but not totally succeed. Doing your solution on the app is throwing a NullPointerException, so until I figure that issue out, I can't tell how successful it is in normal situations. Jul 2, 2012 at 6:29
2

Additionally to the two previous correct answers I had to add --target android-16 because I was getting an "Error: The project either has no target set or the target is invalid."

So in my case

android update lib-project -p . --target android-16

Did it. (replace the 16 as you need)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.