美文网首页
Glide 集成 OkHttp2.x 、OkHttp3.x 和

Glide 集成 OkHttp2.x 、OkHttp3.x 和

作者: devstrongzhao | 来源:发表于2017-12-22 11:18 被阅读0次

    由于 Android 6.0 以后废除了 httpclient , glide 加载网络图片需要自己集成网络访问库了

    第一步添加项目依赖

    dependencies {           compile 'com.github.bumptech.glide:glide:3.7.0'   }

    第二步 集成网络访问库

        1 集成 okhttp2.x

            在 build.gradle 添加

            dependencies {

                // 这个是用来对接 okhttp2.x 的

                compile   'com.github.bumptech.glide:okhttp-integration:1.4.0@aar'

                // okhttp2.x 的依赖

                compile    'com.squareup.okhttp:okhttp:2.2.0'

            }

    2 集成 okhttp 3.x

    在 build.gradle 添加

            dependencies

                { .

                    // 这个是用来对接 okhttp3.x 的

                     compile   'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'

                    // okhttp3.x 的依赖

                      compile   'com.squareup.okhttp3:okhttp:3.2.0'

                }

    注意:如果出现找不到okhttpClient那么就是对接引用出了问题,比如自己引用okhtpp3.x 用来对接的是okhttp那么就会出错。自己遇到过

    3 集成 Volley

    在 build.gradle 添加

            dependencies {

                // 这个是用来对接 volley 的

                compile'com.github.bumptech.glide:volley-integration:1.4.0@aar'

                // volley 的依赖

                compile'com.mcxiaoke.volley:library:1.0.8'

              }

    相关文章

      网友评论

          本文标题:Glide 集成 OkHttp2.x 、OkHttp3.x 和

          本文链接:https://www.haomeiwen.com/subject/naetgxtx.html