代码之家  ›  专栏  ›  技术社区  ›  user9347532

无法解析:com。安卓支持:支持兼容:27.2.0

  •  1
  • user9347532  · 技术社区  · 6 年前

    我的应用程序gradle中的依赖项有问题:

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "fr.android.MyApp"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),   'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:25.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:support-compat:27.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-   core:3.0.2'
    }
    apply plugin: 'com.google.gms.google-services'
    

    获取错误的行是:

    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    

    它显示:未能解析:com。安卓支持:动画矢量可绘制:27.1.1

    以及:

    enter image description here

    我还发现:配置“compile”已经过时,并被“implementation”和“api”所取代。 将于2018年底拆除。

    这是我的身材。格拉德尔:

    // Top-level build file where you can add configuration options common to all   sub-projects/modules.
    
    buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.1'
          }
       }
    
    allprojects {
    repositories {
        google()
        jcenter()
       }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    

    有没有办法解决这个问题?提前谢谢。

    2 回复  |  直到 6 年前
        1
  •  2
  •   AtifSayings    6 年前

    这是因为您使用了appcompat库的旧版本 i、 e:

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

    将其版本从v7:25.1.1更改为27.1.1

    示例:

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:support-compat:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-   core:3.0.2'
    }
    

    更改后同步项目

        2
  •  0
  •   hientp    6 年前

    所有com。安卓支持必须使用完全相同的版本规范

    您使用 animated-vector-drawable:27.1.1 at版本 27.1.1 support-compat at版本 27.2.0 。您应该使它们具有相同的版本。