Glide 集成 OkHttp2.x 、OkHttp3.x 和

2017-12-22  本文已影响0人  devstrongzhao

由于 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'

          }

上一篇下一篇

猜你喜欢

热点阅读