• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Glide适配Androidx

武飞扬头像
tcd
帮助1

项目地址glide

1. Android Studio中使用Glide

Glide从4.9.0版本之后支持Androidx(最新已经到glide.4.13.1),在使用As时可以按照该项目的介绍,直接在Gradle中进行如下配置:

repositories {
   谷歌()
   mavenCentral()
}

dependencies {
    implementation 'com.github.bumptech.glide:glide:4.13.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
}

或者直接下载相关的库包到项目的app/libs目录下,具体用到哪些库见文章最后,主要有.jar&.aar两种格式的库包,然后直接右键相应的包选择“Add As Library”使用该库,或者直接在Gradle中进行如下配置:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.aar'])
    // 后面两项在使用Glide时会用到,否则会出现加载不了图片的情况
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.exifinterface:exifinterface:1.2.0'  
}

2. Android源码中使用支持Androidx的Glide

在源码环境编译项目,需要在Android.mk中对要用到的依赖库进行配置:

aar格式库包

LOCAL_STATIC_ANDROID_LIBRARIES := \
        androidx.exifinterface_exifinterface \
        androidx.vectordrawable_vectordrawable-animated
LOCAL_STATIC_JAVA_AAR_LIBRARIES := library-common-release \
        glide-4.13.1 \
        gifdecoder-4.13.1 \
        disklrucache-4.13.1
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
       glide-4.13.1:libs/glide-4.13.1.aar  \
       gifdecoder-4.13.1:libs/gifdecoder-4.13.1.aar \
       disklrucache-4.13.1:libs/disklrucache-4.13.1.aar

jar格式的包只需将LOCAL_STATIC_JAVA_AAR_LIBRARIES改为LOCAL_STATIC_JAVA_LIBRARIES即可

3. 相关库

一般情况下下载如下三个库即可:
GlideGlide GIF Decoder LibraryGlide Disk LRU Cache Library
还需添加两个androidx库,如上面Gradle及Android.mk里配置的exifinterfacevectordrawable-animated

另外如果需要更多的依赖库见:Group: GitHub Bumptech Glide

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgkhhkg
系列文章
更多 icon
同类精品
更多 icon
继续加载