41.Android aaptツール


41.Android aaptツール
  • Android aaptツール
  • aapt紹介
  • aapt環境構成
  • aapt list
  • aapt dump
  • aapt package
  • その他命令

  • aapt紹介
    公式文書を参照してください.http://www.androidcn.net/wiki/index.php/Reference/aapt
    aapt stands for Android Asset Packaging Tool and is included in the tools/directory of the SDK. This tool allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets.
    Though you probably won’t often use aapt directly, build scripts and IDE plugins can utilize this tool to package the apk file that constitutes an Android application.
    For more usage details, open a terminal, go to the tools/directory, and run the command:
    Linux or Mac OS X: ./aapt Windows: aapt.exe
    aaptはAndroid Asset Packaging Toolで、SDKのtools/ディレクトリの下にあります.このツールはZIP形式のドキュメント添付ファイル(zip,jar,apk)を表示、作成、更新することができます.リソースファイルをバイナリファイルにコンパイルすることもできます.
    aaptツールを直接使用したことがないかもしれませんが、build scriptsとIDEプラグインはこのツールを使用してapkファイルをパッケージしてAndroidアプリケーションを構成します.
    詳細については、ターミナルコンソールを開き、tools/ディレクトリの下でコマンド:Linux or Mac OS X:./aapt Windows:aapt.exeを実行します.
    aapt環境構成
    aaptツールは、sdk/buid-tools/android-[version]/aaptにあります.
  • Windows環境であれば、直接環境変数にPATHを配置し、sdk/buid-tools/android-[version]に指定すればよい.
  • Mac環境では、Oh My Zshを使用していますので、直接vi ~/.zshrcで、以下は私の構成です:
  • # Add Android build-tools AAPT variable
    AAPT_HOME=/Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/build-tools/23.0.2
    export AAPT_HOME
    export PATH=$PATH:$AAPT_HOME

    コマンドラインの下にaaptと入力します.
    aaptのすべてのコマンドと、コマンドに対応するパラメータが表示されます.
    aapt list
    aapt l[ist] [-v] [-a] file.{zip,jar,apk} List contents of Zip-compatible archive.
  • apkディレクトリの表示:aapt l *.apk
  • apkディレクトリを表示し、aapt l -v *.apkMethod:圧縮形式、DeflateまたはStoredを表形式で出力します.Ratio:圧縮率CRC-32:サイクル冗長検査
  • apkディレクトリの詳細表示:aapt l -a *.apk
  • aapt dump
    aapt d[ump] [–values] [–include-meta-data] WHAT file.{apk} [asset [asset …]] strings Print the contents of the resource table string pool in the APK. badging Print the label and icon for the app declared in APK. permissions Print the permissions from the APK. resources Print the resource table from the APK. configurations Print the configurations in the APK. xmltree Print the compiled xmls in the given assets. xmlstrings Print the strings of the given compiled xml assets.
  • apk:package、sdkValersion、targetSdkValersion、アプリケーション-label、launchable-activity、feature-groupなどの情報を表示:aapt d badging *.apk
  • apk権限の表示:aapt d permissions *.apk41.Android aapt工具_第1张图片
  • apkリソースの表示:aapt d resources *.apk
  • apk構成の表示:aapt d configurations *.apk
  • xmlのツリー構造を表示:aapt d xmltree *.apk res/*.xml41.Android aapt工具_第2张图片
  • xml内のすべてのstringを表示:aapt d xmlstrings *.apk res/*.xml41.Android aapt工具_第3张图片
  • 情報表示後出力ファイル:aapt d ... >*.txt41.Android aapt工具_第4张图片表示出力:41.Android aapt工具_第5张图片
  • aapt package
  • R.javaの生成:プロジェクトディレクトリの下にナビゲートaapt package -m -J ~/temp/ -S app/src/main/res -I /Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-23/android.jar -M /Users/CaMnter/GitHub/AndroidLife/app/src/main/AndroidManifest.xml-J~/temp/:出力ディレクトリ-S app/src/main/resの設定:リソースファイルresディレクトリ-I/Users/CaMnter/Android/adt-bundle-mac-x 86_64-20140702/sdk/platforms/android-23/android.jar:android.jarパス**-M/Users/CaMnter/GitHub/Android Life/app/src/main/Android Manifest.xml:**Android Manifest絶対パス
  • リソースファイルを生成するか、プロジェクトディレクトリの下に配置するかaapt package -f -M /Users/CaMnter/GitHub/AndroidLife/app/src/main/AndroidManifest.xml -S app/src/main/res -A app/src/main/assets -I /Users/CaMnter/Android/adt-bundle-mac-x86_64-20140702/sdk/platforms/android-23/android.jar -F ~/log/resouces***-M/Users/CaMnter/GitHub/Android Life/app/src/main/Android Manifest.xml:**Android Manifest絶対パス-S app/src/main/res:リソースファイルresディレクトリ-A app/src/main/assets:assetsディレクトリ-I/Users/CaMnter/Android/adt-bundle-mac-x 86_64-20140702/sdk/platforms/android-23/android.jar:android.jarパス-F~/log/resouces:resouces.arsc格納パス
  • その他のコマンド
    aaptバージョンの出力
    aapt v[ersion] Print program version.
    apkで指定したファイルを削除
    aapt r[emove] [-v] file.{zip,jar,apk} file1 [file2 …] Delete specified files from Zip-compatible archive.
    指定ファイルをapkに追加
    aapt a[dd] [-v] file.{zip,jar,apk} file1 [file2 …] Add specified files to Zip-compatible archive.