your programing

Androidx 프로젝트에서 Android 지원을 사용한 라이브러리를 사용할 수 있습니까?

lovepro 2020. 12. 29. 08:06
반응형

Androidx 프로젝트에서 Android 지원을 사용한 라이브러리를 사용할 수 있습니까?


알아요, androidx 및 multidex 오류를 일으키는 지원 종속성 우리는 androidx 및 android 지원을 동시에 사용할 수 없습니다. 그래서 나는 완전히 androidx로 마이그레이션합니다. 하지만 내 의존성 라이브러리 중 하나는 안드로이드 지원 "lottie"를 사용했습니다.

위 상황에서 우리는 무엇을 할 수 있습니까? 내 프로젝트에서 'lottie'를 제거해야합니다.

아래는 내 gradle입니다.

defaultConfig {
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }

    ext{
    lottieVersion = "2.5.4"
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    def androidx = "1.0.0-rc01"
    api "androidx.constraintlayout:constraintlayout:1.1.2"
    api "androidx.appcompat:appcompat:$androidx"
    api "androidx.recyclerview:recyclerview:$androidx"
    api "androidx.cardview:cardview:$androidx"
    api "androidx.core:core-ktx:$androidx"
    api "com.google.android.material:material:1.0.0-rc01"
    implementation "com.google.code.gson:gson:2.8.5"
    implementation "androidx.multidex:multidex:2.0.0"
    implementation "com.airbnb.android:lottie:$lottieVersion"
    }

Jetifier프로젝트에서 활성화 하면 기본적으로 Android Support Library프로젝트 종속성의 종속성이 AndroidX-ones 교환됩니다. (예 : Lottie 종속성은 Support에서 AnroidX로 변경됩니다)

Android Studio 문서 ( https://developer.android.com/studio/preview/features/ )에서 :

Android Gradle 플러그인은 gradle.properties 파일에서 설정할 수있는 다음 전역 플래그를 제공합니다.

  • android.useAndroidX : true로 설정하면이 플래그는 지금부터 AndroidX 사용을 시작할 것임을 나타냅니다. 플래그가 없으면 Android Studio는 플래그가 false로 설정된 것처럼 작동합니다.
  • android.enableJetifier : true로 설정되면이 플래그는 기존 타사 라이브러리를 AndroidX 용으로 작성된 것처럼 자동으로 변환하기 위해 도구 지원 (Android Gradle 플러그인에서)을 원함을 나타냅니다. 플래그가 없으면 Android Studio는 플래그가 false로 설정된 것처럼 작동합니다.

Jetifier의 전제 조건 :

  • 당신은 적어도 사용해야합니다 Android Studio 3.2

jetifier를 활성화하려면 다음 두 줄을 gradle.properties파일에 추가하세요 .

android.useAndroidX=true
android.enableJetifier=true

마지막으로 jetifier일부 라이브러리 (예 : Dagger Android)에 여전히 문제가 있으므로 AndroidX의 릴리스 노트를 확인하십시오 . https://developer.android.com/topic/libraries/support-library/androidx-rn


수동으로 추가 android.useAndroidX=true하고 android.enableJetifier=true저에게 힘든 시간을줍니다. 오류가 발생하거나Suggestion: add 'tools:replace="android:appComponentFactory"' to <application>

프로젝트에서 Jet-fire를 활성화하려면 android Studio에 옵션이 있습니다.

프로젝트 선택 ---> 오른쪽 클릭

앱 ----> 리팩터링 ----> AndroidX로 마이그레이션

아래 이미지에 표시 :-

여기에 이미지 설명 입력

Migrate to AndroidX를 클릭 한 후 .

프로젝트에 대한 확인 및 백업을 요청합니다.

여기에 이미지 설명 입력

마지막 단계에서는 리팩터링을 요청합니다.

여기에 이미지 설명 입력

After doing Refactor check your gradle.properties have android.useAndroidX=true and android.enableJetifier=true. If they are not then add these two lines to your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

You need not to worry

Just enable Jetifier in your projet.

  • Update Android Studio to 3.2.0 or newer.
  • Open gradle.properties and add below two lines.

    android.enableJetifier=true
    android.useAndroidX=true
    

It will convert all support libraries of your dependency to AndroidX at run time (you may have compile time errors, but app will run).


I used these two lines of code in application tag in manifest.xml and it worked.

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

Source: https://github.com/android/android-ktx/issues/576#issuecomment-437145192


API 29. + 사용 AndroidX 라이브러리. API 29. +를 사용하는 경우이를 제거 할 수 없습니다. AndroidX를 제거하려면 SDK에서 전체 29. + API를 제거해야합니다.

SDK 설정

이것은 잘 작동합니다.

참조 URL : https://stackoverflow.com/questions/52033810/can-i-use-library-that-used-android-support-with-androidx-projects

반응형