首页 > 技术文章 > android studio出现 Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

changweijinghu 2021-06-17 16:22 原文

新的android studio  (4.2)已经不支持旧有的

com.android.tools.build:gradle:2.3.3

了,有些方法和类会找不到。

去build.gradle中把这个classpath换成最新的版本。最好也把gradle和gradle wrapper的版本也弄到最新。比如:

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
google()
}
}

  如上图,别忘了 maven也加上google()哦

推荐阅读