How to add appcompat in gradle?
Asked Answered
D

5

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

}
Dinger answered 21/6, 2020 at 9:10 Comment(2)
Seems like there is no this specific version of appcompat, do you need this version or any version of appcompat will be fine?Hammel
@Hammel The appcompat-v7:24.2.1 exists but you have to add the google() repo.Canada
A
17

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()
        }
...
Abecedarium answered 21/6, 2020 at 9:28 Comment(0)
C
4

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'
Canada answered 21/6, 2020 at 11:49 Comment(0)
A
1

Seems you are using old version appCompat.

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

Archivolt answered 21/6, 2020 at 9:30 Comment(0)
W
1

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'
Wenda answered 21/6, 2020 at 9:36 Comment(0)
T
0

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'

Tambratamburlaine answered 21/6, 2020 at 9:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.