I have an android project which has an Ant buildfile. It works great via the command-line:
rascher@coltrane:~/git/$ ant Buildfile: build.xml [setup] Android SDK Tools Revision 8 [setup] Project Target: Android 2.1-update1 [setup] API level: 7 [setup] ... etc etc etc ...
But when I try to use this in eclipse, build.xml
has a red-X.
<?xml version="1.0" encoding="UTF-8"?> <project name="MyWonderfulProject" default="help">
<project
is underlined with the error: Default target help does not exist in this project
It seems like everybody else on the internet has this issue, and it seems to be caused by the fact that build.xml
is using directives that come from the multiple nested android-specific files that this buildfile imports.
I have other projects in my workspace that use Eclipse's build mechanism, so I know that my environment is able to compile, run, and deploy Android applications without an issue. But this buildfile is giving me headaches.
What is the fix?
Apache ANT is tool to automate build of java projects ,by providing instructions in build. xml file ,eclipse uses ant to build projects . I suggest Android Studio as IDE which uses Gradle for build of android project and that is officially supported by google.
Open the Java project in Eclipse. Right click the project. Go to Export. In the General section select Ant build files and click "Next"
Option 1:
Import the Android ant template file in the build.xml file. Assuming you have sdk.dir
defined in local.properties
and pointing to your Android installation directory, add the following under the project element:
<import file="${sdk.dir}/platforms/${target}/templates/android_rules.xml" />
Option 2:
To actually use the Android ant targets in the Eclipse ant perspective, the above will not help. There seems to be some general level incompatibility that I haven't figured out to resolve completely, but to get things working at a satisfactory level though you can:
This will have an impact on all projects and ignore actual errors, so it's not a perfect solution. But you can use the Android build options inside Eclipse, as well as from the command line.
This doesn't fix the problem, but it will make Eclipse stop getting in your way. Go to Window > Preferences > Ant > Editor
, and select the Problems
tab. Check the ignore all buildfile problems
box.
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