LoginSignup
4
4

More than 3 years have passed since last update.

AndroidX 導入手順

Last updated at Posted at 2019-08-09

AndroidXとは?

  • AndroidチームがJetpack内でのライブラリの開発、テスト、パッケージ、バージョン管理、リリースに使用しているオープンソースプロジェクト。

  • 元のAndroid Support Libraryを大幅に改良。Support Libraryと同様に、AndroidXもAndroid OSとは個別にリリースされ、Androidの下位互換を提供する。

  • 同等の機能と新しいライブラリを提供することで、完全にSupport Libraryの代わりとなる。

※SupportLibraryはv28で終了しているので、早めにAndroidXへ移行するのがおすすめ

AndroidXを使用する

新規プロジェクトでAndroidXを使用する方法

build.gradle(app)で次の2つを設定
Compile SDKをAndroid 9.0(API Lv28)以上

build.gradle
android {
    compileSdkVersion 28
    ...

dependenciesのSupportLibraryをAndroidXに書き換える

build.gradle
// 既存のSupport Library
dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}

// AndroidXに書き換える
dependencies {
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

gradle.propertiesで次の2つを設定

gradle.properites
android.useAndroidX=true
android.enableJetifier=true

既存のプロジェクトを移行する方法

今回は取り扱わないので下記を参照してください。
AndroidX への移行

バージョンについて

依存関係を記載する際にどのバージョンが適切なのか迷う場合があると思います。そのときは下記を参照して確認してみてください。

以上

参考

4
4
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
4
4