1、配置OkHttp3,在Module的build.gradle中在dependencies中加入一行:impl髫潋啜缅ementation 'com.squareup.okhttp3:okhttp:3.14.1'

2、最新版本支持的API是21,Android5.0

3、因此修改minSdkVersion的值为21

4、修改完毕之后,点击Sync now。有时候会下载失败,try again重试一下。
5、然后在测试文件中来编写测试代码。加上@Test注解。

6、定义OkHttpClient,然后编写一个Request对象,采用Request.Builder().url("https://www.baidu.com").build实例化。然后利用client.newCall(request).execute(),执行请求。得到一个Response,利用response.body().string()方法得到响应信息。

7、Log.i打印一下response信息。
