新しくなった Android Asset Studio でマテリアルアイコンを自在に加工するべし

作者の Roman Nurik さんがつぶやいています.

使ってみましょう.

Android Asset Studio

Google から公開されているマテリアルデザインのアイコンを元に色やサイズやエフェクトをお好みにブラウザ上で設定してダウンロードできます.

編集後は, resディレクトリ以下解像度別のディレクトリの構造に合わせて作成されたzipアーカイブをダウンロードできます.


$ zipinfo -1 ic_launcher.zip
res/mipmap-xxxhdpi/ic_launcher.png
web_hi_res_512.png
res/mipmap-xxhdpi/ic_launcher.png
res/mipmap-xhdpi/ic_launcher.png
res/mipmap-hdpi/ic_launcher.png
res/mipmap-mdpi/ic_launcher.png


$ zipinfo -v ic_launcher.zip
Archive:  ic_launcher.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                    129862 (000000000001FB46h)
  Actual end-cent-dir record offset:        129840 (000000000001FB30h)
  Expected end-cent-dir record offset:      129840 (000000000001FB30h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 6 entries.
  The central directory is 455 (00000000000001C7h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 129385 (000000000001F969h).


Central directory entry #1:
---------------------------

  res/mipmap-xxxhdpi/ic_launcher.png

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2017 Jan 18 12:53:42
  32-bit CRC value (hex):                         5e505e31
  compressed size:                                20038 bytes
  uncompressed size:                              20028 bytes
  length of filename:                             34 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  There is no file comment.

Central directory entry #2:
---------------------------

  There are an extra 16 bytes preceding this file.

  web_hi_res_512.png

  offset of local header from start of archive:   20118
                                                  (0000000000004E96h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2017 Jan 18 12:53:42
  32-bit CRC value (hex):                         bb74dba5
  compressed size:                                74680 bytes
  uncompressed size:                              75392 bytes
  length of filename:                             18 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  There is no file comment.

Central directory entry #3:
---------------------------

  There are an extra 16 bytes preceding this file.

  res/mipmap-xxhdpi/ic_launcher.png

  offset of local header from start of archive:   94862
                                                  (000000000001728Eh) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2017 Jan 18 12:53:42
  32-bit CRC value (hex):                         ca100bd5
  compressed size:                                15772 bytes
  uncompressed size:                              15790 bytes
  length of filename:                             33 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  There is no file comment.

Central directory entry #4:
---------------------------

  There are an extra 16 bytes preceding this file.

  res/mipmap-xhdpi/ic_launcher.png

  offset of local header from start of archive:   110713
                                                  (000000000001B079h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2017 Jan 18 12:53:42
  32-bit CRC value (hex):                         6551b330
  compressed size:                                8409 bytes
  uncompressed size:                              8404 bytes
  length of filename:                             32 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  There is no file comment.

Central directory entry #5:
---------------------------

  There are an extra 16 bytes preceding this file.

  res/mipmap-hdpi/ic_launcher.png

  offset of local header from start of archive:   119200
                                                  (000000000001D1A0h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2017 Jan 18 12:53:42
  32-bit CRC value (hex):                         44371c4a
  compressed size:                                6539 bytes
  uncompressed size:                              6534 bytes
  length of filename:                             31 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  There is no file comment.

Central directory entry #6:
---------------------------

  There are an extra 16 bytes preceding this file.

  res/mipmap-mdpi/ic_launcher.png

  offset of local header from start of archive:   125816
                                                  (000000000001EB78h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2017 Jan 18 12:53:42
  32-bit CRC value (hex):                         4fce9139
  compressed size:                                3492 bytes
  uncompressed size:                              3487 bytes
  length of filename:                             31 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

かんたんなアイコンであれば簡単に素早く作成できます.

Windows版デスクトップアプリ(.exe形式)もある模様.

romannurik/AndroidAssetStudio: A set of web-based tools for generating graphics and other assets that would eventually be in an Android application's res/ directory.


新しくなった Gradle Tips and Recipes : 各ソースセットの配置の確認

新しくなってます, Gradle Tips and Recipes .

Gradle Tips and Recipes | Android Studio

Gradle が利用するディレクトリ

それぞれ指定できるのはなんとなく知っていたが.


android {
  ...
  sourceSets {
    main {
      java.srcDirs = ['other/java']
    ....

これらの記述無し無指定のデフォルトの場合はどのディレクトリが利用対象になっているのか.

ドキュメントやツールスクリプトなど,

Git に登録して管理はしたいが, アプリ自体に影響ない位置はどこなのか??

と思っていましたが.

Configure Build Variants | Android Studio

右上 [Gradle] タブから以下ダブルクリックで実行.

MyApplication > Tasks > android > sourceSets

Gradle が認識している対象ディレクトリ群が Gradle Console に出力される.


------------------------------------------------------------
Project :app
------------------------------------------------------------

...

debug
----
Compile configuration: compile
build.gradle name: android.sourceSets.debug
Java sources: [app/src/debug/java]
Manifest file: app/src/debug/AndroidManifest.xml
Android resources: [app/src/debug/res]
Assets: [app/src/debug/assets]
AIDL sources: [app/src/debug/aidl]
RenderScript sources: [app/src/debug/rs]
JNI sources: [app/src/debug/jni]
JNI libraries: [app/src/debug/jniLibs]
Java-style resources: [app/src/debug/resources]

これで, AndroidStudio でファイルを操作しながらの Git 管理しても安心です.

他にもあれこれ小技がのっていますよ, このレシピ.


あやしい Project Structure ダイアログを Experimental にしてライブラリ更新を正しく把握する

「かんたんにGUI上で編集する」という考え方なのだろうと思いますが, 今や設定項目の多さや複雑さに対応できているのか疑問に思うダイアログの「Project Structure」.

実行時の挙動が問題ない場合, 設定ファイル自体を直接GUIに対応するように修正する, というのもなんともおかしな話で.

一方, 利用しているライブラリの最新のバージョンを確認したいときはどうしたらいいのか.

Settings > Editor > Inspections > "Newer Library Versions Available"

サード・パーティのライブラリに関してはチェックしていない? の変化なし.

Experimental な機能を使う

Preferences > Build.. > Gradle > Experimental

そして, Project Structure を開くと, ライブラリ同士の依存関係を見ることができたり,

JCenter を利用したライブラリのバージョン確認もできます.

昔は, フツーにチェックしてくれたように思うが, いつからこうなった?


Gradle 3.3 は本当に100倍以上の速さになったのか

アナウンス後, 3.3 公開されてます.

Gradle 3.3 Release Notes

英語だけど「100倍以上速い」とか書いてない?

試してみました.

gradle-wrapper.properties を 3.2 から 3.3 に.


distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip


$ ./gradlew -v

------------------------------------------------------------
Gradle 3.3
------------------------------------------------------------

Build time:   2017-01-03 15:31:04 UTC
Revision:     075893a3d0798c0c1f322899b41ceca82e4e134b

Groovy:       2.4.7
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_92 (Oracle Corporation 25.92-b14)
OS:           Mac OS X 10.12.2 x86_64

Built-in-shrinker で min21.

更新前 (3.2).

更新後 (3.3).

何回かやってみたけど だいたい2-3倍くらい.

環境などにも依ると思うけどもアナウンスはいつも盛り気味?

75%速度向上という Gradle 3.0 を Android Studio で試す

オプションに「–profile」をつけて Run時間が1分から2秒になった話


PNG から WebP へ一括変換できるようになった Android Studio 2.3

Androi 4.2.1 - API 17 からフルサポートできる WebP ですが.

夏のアプリ容量ダイエット!WebPでスリムなアプリになろう! - HOME'S Designer's Blog | ホームズ デザイナーズ ブログ

特にこだわる必要のない画像であればかなりのサイズの削減となります.

apk 上でもかなりの削減となり, 端末への転送時間を短縮し, 開発の時間効率も上がることになります.

Android Studio 2.3 (2017-01-04 現在 beta) では, PNG - WebP 変換が一括で容易にできるようになっています.

無造作に, res ディレクトリに配置した画像リソースを右クリックから変換できます.

ディレクトリから一括変換も可能になっています.

と, 削減量や変換後と比較確認しながら簡単にできるようになりました.

WebP から PNG へ再度変換もできるようです.

お試しあれし.