gpt4 book ai didi

java - Android Studio 编译错误 : Could not find runtime-2. 4.0.aar

转载 作者:行者123 更新时间:2023-12-05 05:52:07 24 4
gpt4 key购买 nike

当尝试在我的 android 设备上运行我的应用程序时,出现以下错误:

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find runtime-2.4.0.aar (androidx.lifecycle:lifecycle-runtime:2.4.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-runtime/2.4.0/runtime-2.4.0.aar

Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

我试过:

  1. 将我的 compileSdkVersion 和 minSdkVersion 设置为 31
  2. 检查该库是否确实存在于 maven 存储库中 here

我的build.gradle(应用级别)


plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
compileSdkVersion 31

defaultConfig {
applicationId "com.brianokoth.skillsapp"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-firestore:4.1.0'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.4.0'
}

我的build.gradle(项目级别)


// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}

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

我期待任何帮助。

最佳答案

首先,您可以尝试 File -> Sync Project With Gradle Files 以确保它已正确导入。其次,最好添加所有 life cycle dependencies 而不是只添加一个,那已经过时了。所以删除当前的并改用这些:

 implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha02"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"

关于java - Android Studio 编译错误 : Could not find runtime-2. 4.0.aar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70275458/

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