我创建了一个新的 android 项目它在构建时显示错误
我尝试了现有的答案
错误是
错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析 junit:junit:4.12。
错误:无法解析“:app@releaseUnitTest/compileClasspath”的依赖关系:无法解析 junit:junit:4.12。
错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析 junit:junit:4.12。
错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析 com.google.code.findbugs:jsr305:2.0.1。
我的 gradle 文件的依赖项部分
dependencies
{
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
我不明白这是我的第一个项目。
我的项目等级是
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序等级是
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
android
{
configurations.all
{
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies
{
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
我试图混合 AppCompat 和 Jetpack 依赖项,但你不能这样做。
我想我可能没有为 Jetpack 库设置正确的存储库(为什么它找不到任何 Jetpack 库)。
不要使用:实现 'androidx.appcompat:appcompat:1.0.2' 。(这是 Jetpack)——使用它的 AppCompat 版本(此外 - Jetpack 与 28.x 之前的 Appcompat 版本不一致)。最重要的是,去掉任何写着(androidx)的东西。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6354 次 |
| 最近记录: |