LoginSignup
24
23

More than 5 years have passed since last update.

Androidのantビルド時に知っておくと便利なantタスク

Posted at

Androidの開発においては大抵eclipseを使用してビルドをしていると思われますが、ときおりantを使用してビルドをする場面があります。

そんな時にはandroid update projectしてからant debugをするのが王道の手順ですが、ant debug以外にも便利なantタスクがAndroid SDKには用意されています。

installタスク

プロジェクトをビルドした後に、そのapkファイルを端末にインストールしてくれます。
ビルド後にadb install Activity.apkをしている人も多いと思いますが、installタスクを利用したほうがコマンドも減って楽です。

ant debug install     #debugビルド後インストール
ant release install   #releaseビルド後インストール

installd, installrタスク

ビルドせずにAPKの端末インストールのみを行います。

ant installd   #debugビルドしたapkをインストール
ant installr   #releaseビルドしたapkをインストール

uninstallタスク

端末にインストールしたアプリをアンインストールします。
こちらもadb uninstallでもできますが、パッケージ名を指定しなくても良いぶん楽です。

ant unsintall

応用

antタスクを並べれば順次実行されるので、色々な組み合わせが可能です。
よくやるのは、

プロジェクトをクリーンしてdebugビルド後、端末からアプリをアンインストールしてからインストール

ant clean debug uninstall install

こんなかんじです。

ant helpすると使用可能なantタスクの一覧が見られます。

24
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
23