Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'

}
like image 811
raja love kumar Avatar asked Nov 30 '22 13:11

raja love kumar


2 Answers

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()
        }
...
like image 181
Phantom Lord Avatar answered Dec 04 '22 15:12

Phantom Lord


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'
like image 32
Gabriele Mariotti Avatar answered Dec 04 '22 15:12

Gabriele Mariotti