如何在gradle中添加appcompat?

raj*_*mar 3 android android-layout android-support-library androidx

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
Run Code Online (Sandbox Code Playgroud)

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

}
Run Code Online (Sandbox Code Playgroud)

Pha*_*ord 8

更新:从 Android Studio ~4.2.0 这将是:

repositories {
        google()
        mavenCentral()
    }
Run Code Online (Sandbox Code Playgroud)

在项目 gradle.build 中:

repositories {
        google()
        jcenter()
    }
Run Code Online (Sandbox Code Playgroud)


小智 0

建议您使用Android X迁移到最新的支持库,您尝试使用的版本是不再维护的旧版appcompat,试试这个

implementation 'androidx.appcompat:appcompat:1.1.0'