安转Android Studio 3.4,新建的工程模板并不能正常编译通过,需要进行一些设定。
1. 新建的工程模板后,自动进行Sync(下载junit等的依赖库失败),会有如下错误:
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download junit.jar (junit:junit:4.12)
Show Details
Affected Modules: app
对应方法有两个:
方法1。如果不需要junit,在build.gradle中注掉即可:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'androidx.test:runner:1.2.0'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
再次Sync成功。build成功。
方法2。在build.gradle(project)中加入mavenCentral()就没问题了
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
}
allprojects {

最低0.47元/天 解锁文章
4391

被折叠的 条评论
为什么被折叠?



