raja love kumar
raja love kumar

Reputation: 71

How to add appcompat in gradle?

Could not find com.android.support:appcompat-v7:24.2.1.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/support/appcompat-v7/24.2.1/appcompat-v7-24.2.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
    project :app

Here the build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "24.0.3"
    useLibrary  'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.rts.dcmote.dcmote"
        minSdkVersion 15
        targetSdkVersion 30
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:24.2.1'

}

Upvotes: 7

Views: 15064

Answers (5)

Phantom Lord
Phantom Lord

Reputation: 701

UPDATE (June 2020): For Android Studio >=4.2.0, build.gradle in the root of the project, will be like this:

buildscript {
    repositories {
            google()
            mavenCentral()
        }
...

Upvotes: 18

Mutasim
Mutasim

Reputation: 36

Note: With the release of Support Library 28.0.0, the android.support-packaged libraries are deprecated and replaced by individually-versioned Jetpack libraries packaged as androidx. The initial 1.0.0 release of the Jetpack libraries provides parity with Support Library 28.0.0 and provides a starting point for migrating to the new androidx packaging.

The existing android.support-packaged libraries will continue to work; however, they will not receive any updates beyond 28.0.0 and will not be compatible with new Jetpack libraries. Historical artifacts (those versioned 27 and earlier, and packaged as android.support) will remain available on Google Maven. All new artifacts will be packaged as androidx and will require migration from android.support to androidx. You can see the rest of the documentation here Google Developer

you could use this one , check the last version here Google Developer

implementation 'androidx.appcompat:appcompat:1.3.0'

Upvotes: 1

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363935

The dependency:

implementation 'com.android.support:appcompat-v7:24.2.1'

is very old but it exists.
Check in your top-level build.gradle the repositories block. You have to add the google() repo.

allprojects {
    repositories {
        google()
        jcenter()
    }
}

In any case consider to:

  • use the last release of Support Library 28.0.0 instead of 24.2.1
  • to migrate to androidx libraries since the support libraries are deprecated. In this case use (you need also in this case the google() repo)
    implementation 'androidx.appcompat:appcompat:1.1.0'

Upvotes: 4

Ranjithkumar
Ranjithkumar

Reputation: 18396

Seems you are using old version appCompat.

You can migrate all your code using Refactor -> Migrate to AndroidXenter image description here

Upvotes: 1

Jaime
Jaime

Reputation: 388

It is recommended that you migrate to the latest support library using Android X, the version you are trying to use is the legacy appcompat that is no longer maintained, try this

implementation 'androidx.appcompat:appcompat:1.1.0'

Upvotes: 0

Related Questions