简体   繁体   中英

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

When trying to run my application on my android device, I get the following error:

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

I have tried:

  1. Setting my compileSdkVersion and minSdkVersion to 31
  2. Checking that the library does indeed exist in the maven repository here

My build.gradle (app level)


    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'
    }

My build.gradle (project level)


    // 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
    }

I look forward to any assistance.

first you could try File -> Sync Project With Gradle Files just to make sure it has been properly imported. Second it's better to add all the life cycle dependencies instead of just one, that's obsolete. so delete the current one and use these one instead:

 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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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