gpt4 book ai didi

android - 在android中编译项目时如何修复这些关于无法找到依赖项的错误?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:25 26 4
gpt4 key购买 nike

当我尝试构建我的项目时遇到这些错误,看起来它认为我有 2 个相同的库,但我不确定为什么:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.room:room-testing:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.room:room-testing:2.1.0-alpha02.
Open File
Show Details

这是我的build.gradle文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "com.andydaykin.timer"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
dexOptions {
// release & debug is in project animators
matchingFallbacks = ['release', 'debug']
}
debug {
debuggable true
}
}
compileOptions {
targetCompatibility 1.10
sourceCompatibility 1.10
}
}

allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'

implementation ('androidx.legacy:legacy-support-core-utils:1.0.0') {
force = true
}
implementation 'androidx.appcompat:appcompat:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'com.google.guava:guava:24.1-jre'
implementation 'com.google.inject:guice:4.1'
implementation 'com.google.firebase:firebase-appindexing:16.0.2'
implementation 'com.google.android.gms:play-services-analytics:16.0.5'
implementation 'com.google.android.gms:play-services-ads:17.0.0'

implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0"

def room_version = "2.1.0-alpha02"

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

testImplementation "androidx.room:room-testing:$room_version"
}

这是我的顶级 gradle 构建文件:

{

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.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/'
name 'Google'
}
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

我认为这个错误是在升级到 android studio 之后发生的,但我记不清了。我的android studio 版本现在是3.2.1。我之前能够构建这个项目。

最佳答案

在您的顶级 Gradle 文件中,为谷歌服务插件添加类路径。

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
}

您应该检查您的互联网连接、代理或防火墙。

通过以下交叉检查以禁用 Gradle Offline。

window :

Settings >Gradle >Disable Offline Work

麦克:

Preferences > Build, Execution, Deployment >Gradle >Disable Offline Work

enter image description here

关于android - 在android中编译项目时如何修复这些关于无法找到依赖项的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53440108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com