본문 바로가기
안드로이드

안드로이드X로 프로젝트 마이그레이션 하기

by Dokon Jang 2019. 6. 23.
반응형

기존 안드로이드 프로젝트를 안드로이드X로 마이그레이션 하는 방법입니다.

즉 Android API 28 미만의 프로젝트를 마이그레이션 하는 것이죠.

올해 8월 쯤에 모든 안드로이드 앱은 안드로이드X로 플레이 스토어에 등록해야 하는 것으로 알고 있습니다.

1. 안드로이드 스튜디오를 최신 버전으로 업데이트 합니다.

   (최신버전에서는 안드로이드X로 마이그레이션을 할 수 있는 기능이 있습니다.)

  - 메뉴 Help > Check for update 를 클릭하여 안드로이드 스튜디오를 최신 버전으로 업데이트 합니다.

 

2. 안드로이드 스튜디어에서 메뉴 Refactor > Migrate to AndroidX... 를 클릭합니다.

   - 해당 프로젝트는 마이그레이션이 시작됩니다.

 

 

3. 아래와 같이 오류가 발생하면 Gradle을 3.2.0 이상으로 업데이트 하고, 모듈 Gradle의 compileSdk의 버전을 28로 변경합니다.

(1) Gradle을 3.2.0으로 업데이트 하기

  - 메뉴 File > Project Structure... 을 클릭합니다.

  - Android Gradle Plugin Version은 3.2.0으로 선택하고, Gradle Version은 4.6으로 설정합니다.

 

(2) 모듈 Gradle에서 compileSdkVersion을 28로 변경합니다.

 

4. 안드로이드X로 마이그레이션이 끝나면 아래와 같이 변경됩니다.

(1) 모듈 Gradle의 dependencies는

[변경전]

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26+'
    implementation 'com.android.support:design:26+'
    implementation 'com.android.support:cardview-v7:26+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'


    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.maps.android:android-maps-utils:0.5'
    implementation 'com.google.android.gms:play-services-ads:17+'


    implementation 'com.facebook.android:audience-network-sdk:5.+'
}

[변경후]

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.libraries.places:places-compat:1.1.0'


    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.maps.android:android-maps-utils:0.5'
    implementation 'com.google.android.gms:play-services-ads:17+'


    implementation 'com.facebook.android:audience-network-sdk:5.+'
}

(2) gradle.properties에는 아래의 속성이 추가됩니다.

#AndroidX 이외의 라이브러리 사용
android.enableJetifier=true
#AndroidX 라이브러리 사용
android.useAndroidX=true

 

반응형

댓글