须要在moudle的build.gradle中的dependencies添加依赖android
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
***!!!看清楚所添加的依赖,单词间是不能有空格的
而后在project的build.gradle中记得加上mavenCentral()app
buildscript { repositories { mavenCentral() google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenCentral() google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }