繁体   English   中英

Android Studio 编译错误:找不到 runtime-2.4.0.aar

[英]Android Studio Compile Error: Could not find runtime-2.4.0.aar

当尝试在我的 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 存储库中确实存在该库

我的 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"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM