Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了我可以使用Android支持androidx项目的库吗?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道,androidx and support dependency causing multidex error
我们不能同时使用androidx和android支持.所以我完全迁移到androidx.但我的一个依赖lib使用了android支持“lottie”.

在上述情况下我们能做些什么?我应该从我的项目中删除’lottie’吗?

下面是我的傻瓜

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,这将基本上与AndroidX-1交换项目依赖项中的Android支持库依赖项. (例如,您的Lottie依赖项将从Support更改为AnroidX)

从Android studio文档(https://developer.android.com/studio/preview/features/):

jetifier的先决条件:

>你必须至少使用Android studio 3.2

要启用jetifier,请将这两行添加到gradle.properties文件中:

android.useandroidX=true
android.enablejetifier=true

最后,请查看AndroidX的发行说明,因为jetifier在某些库中仍存在一些问题(例如Dagger Android):https://developer.android.com/topic/libraries/support-library/androidx-rn

大佬总结

以上是大佬教程为你收集整理的我可以使用Android支持androidx项目的库吗?全部内容,希望文章能够帮你解决我可以使用Android支持androidx项目的库吗?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。