Android

[Solved] Dependency ‘androidx.activity:activity:1.8.0’ requires libraries

When we create a new project in Android Studio, and run this project. The compilation fails and this error appears in logcat window.

Solve Dependency ‘androidx.activity:activity:1.8.0’ requires libraries

There are two ways to solve this ‘Dependency ‘androidx.activity:activity:1.8.0′ requires libraries’.

Method 1: Upgrade compiled sdk version

First method is to upgrade the compiled and targeted sdk version from 33 to 34. Upgrade the version and run again the project, the issue will be resolved.


android {
    namespace 'com.android.mydeomo'
    compileSdk 34

    defaultConfig {
        applicationId "com.android.mydeomo"
        minSdk 21
        targetSdk 34
        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
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

Method 2: Downgrade Material plugin

This error can also be resolved by downgrading our material plugin. replace this implemantation: implementation ‘com.google.android.material:material:1.10.0’ with: implementation ‘com.google.android.material:material:1.8.0’

Replace this line

 implementation 'com.google.android.material:material:1.10.0'

To this

 implementation 'com.google.android.material:material:1.8.0'

Now sync project and run again. It will install the app.

If you visit the Maven repository page for material 1.10.0, you will notice a section called ‘Compile Dependencies.’ This section lists the dependencies required for the material dependency to compile and function properly. Typically, these compile dependencies are automatically included when you declare the main dependency in your project.

The first dependency in the list is ‘activity 1.8.0,’ which is only compatible with ‘compileSdk’ versions greater than or equal to 34. To resolve this compatibility issue, you can either downgrade the material dependency or upgrade your project’s ‘compileSdk’ version.

You can also read how to download image from url in android kotlin

Leave a Reply

Your email address will not be published. Required fields are marked *