English 中文(简体)
如何使用Ant构建Android项目?(IntelliJ IDE)
原标题:How do I build an Android project using Ant? (IntelliJ IDE)

我在IntelliJ IDEA IDE中有一个项目,我想建立一个并行的、生产的Ant构建过程,我可以随着时间的推移进行扩展。

我已经使用IntelliJ的功能创建了一个Ant构建文件,它位于build菜单上,因此Ant构建过程正在IDE中运行和工作。一切都很好。

但IntelliJ创建的Ant脚本只是编译到类文件,并没有完成完整的Android构建过程,直到APK(据我所知)。

你能给我指一个参考源(或一个例子)来帮助我理解如何让ANT脚本完成Android项目的完整构建吗?

如果你知道的话,知道如何将其扩展到包括Proguard、生产签名和插入生产映射密钥也是非常有用的:)

最佳回答

以此为起点:

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

我不知道IntelliJ,但我不应该很难用你需要的最频繁的命令创建一个ant文件。

更新:

运行以下命令:

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

这将创建一个项目结构。这包括一个build.xml文件,该文件包含用于构建项目的目标。

要生成应用程序,请在根文件夹(/path/To/project/)中运行:

ant debug

它应该编译您的应用程序。

你可能必须安装或配置ant才能正常工作,但你应该能够自己解决!:)

(所有信息都在我之前发布的链接中)

问题回答

SDK文档中对它进行了很好的描述。只需3个步骤即可实现:

  1. 假设你已经用IntelliJ Idea这样强大的东西开发你的活动一段时间了。所以,正如奥利在评论中提到的,你不必从头开始创建android项目。磨合命令行:

    android更新项目--path“项目路径”--target“android-X”

    其中X是API级别

  2. 在第一步之后,build.xml被自动创建。现在打开IntelliJ,转到ant构建面板并添加build.xml。

  3. 重要的一步是打开已创建任务的属性,并在执行选项卡的命令行中添加调试或释放。

现在你可以跑目标并享受结果了。要编译成已签名的发行版还需要付出更多的努力。

注意:您现有的项目结构应该与android项目相匹配。请查看文档。例如,我将外部库放在“lib”子文件夹中,只有在将“lib”重命名为“libs”后,我才能使其工作





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签