开发者

How do I build an Android project using Ant? (IntelliJ IDE)

I've a project in the IntelliJ IDEA IDE and I want to set up a parallel, production Ant build process that I can extend over time.

I have used IntelliJ's feature to create an Ant build file, and it is on the Build menu, so the Ant build process is running, and working within the IDE. All good.

But the Ant script IntelliJ has created is only compiling to class files, and is not doing a full Android build process through to an APK (as far as I can t开发者_JS百科ell).

Can you point me towards a reference source (or an example) to help me understand how to get an ANT script doing a full build of an Android project?

If you know, would also be v useful to know how to then extend it to include Proguard, production signing, and inserting the production Maps key :)


Use this as a starting point:

http://developer.android.com/guide/developing/other-ide.html

I don't know IntelliJ but I shoudn't be very hard to create an ant file with the most frequent commands you need.

UPDATE:

run the following command:

android create project --target 8 --name "MyFirstProject" --path /path/to/project --activity StartingActivity  --package net.sample.package

This will create a project structure. This includes a build.xml file that contains targets to build the project.

To build the application, in the root folder (/path/to/project/) run:

ant debug

It should compile your application.

You may have to install or configure ant before this works correctly but you should be able to figure it out by yourself! :)

(All the info is in the link I posted earlier)


It's pretty well described in SDK documentation. Just 3 steps to make it work:

  1. Assuming you have been developing your activity for a while with such powerful thing as IntelliJ Idea. So as Ollie mentioned in comment you don't have to create android project from scratch. Run in command line:

    android update project --path "Path to your project" --target "android-X"

    where X is API level

  2. After step one build.xml was created automatically. Now you open IntelliJ, go to ant build panel and add that build.xml.

  3. The important step is to open properties of created task and add debug OR release to command line at execution tab.

Now you can run target and enjoy the result. It will take some more efforts to compile into signed release.

Note: your existing project structure should match to android project. Please review documentation. E.g. I had external library put in "lib" subfolder and I managed it to work only after renaming "lib" to "libs"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜