「Coil」とは?
Android向けの画像ロードライブラリです。
画像ロードライブラリの比較
Android向けの画像ロードライブラリを比較しました。
Picasso | Glide | Coil | |
---|---|---|---|
最新バージョン | 2.71828 | 4.11.0 | 0.9.5 |
最終リリース | 2018/03/08 | 2020/01/09 | 2020/02/09 |
スター数 | 17,418 | 28,772 | 2,998 |
提供元 | Square | Bump Technologies | Coil |
特徴 | Squareが提供している | スター数が多い | Kotlinファースト |
※2020/04/17現在
CoilはPicassoやGlideよりスター数が少ないのですが、最終リリース日が最も新しく、Kotlinファーストに作られているため、選定しました。
選定後に読んだのですが、パフォーマンスを比較した記事を参考にするのもいいと思います。
https://proandroiddev.com/coil-vs-picasso-vs-glide-get-ready-go-774add8cfd40
環境
- OS:macOS Mojave 10.14.6
- Kotlin:1.3.61
- Gradle:5.6.4
- Gradle plugin:3.6.2
- Coil:0.9.5
セットアップ
インストール
appフォルダ配下の「build.gradle」に追加するのみです。
/app/build.gradle
dependencies {
+ implementation 'io.coil-kt:coil:0.9.5'
}
使い方
ライブラリをインポートし、ロードするのみです。
import coil.api.load
imageView.load("{画像のURL}")
私の場合、以下のビルドエラーが発生しました。
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
appフォルダ配下の「build.gradle」にJVMターゲットを指定することで解決しました。
/app/build.gradle
android {
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
}
おわりに
かんたんに画像をURLから取得して表示することができました!
詳細な使い方は公式ドキュメントをご参照ください。
参考リンク
- coil-kt/coil: Image loading for Android backed by Kotlin Coroutines.
- square/picasso: A powerful image downloading and caching library for Android
- bumptech/glide: An image loading and caching library for Android focused on smooth scrolling
- Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper ‘-jvm-target’ option - Qiita