Android Studio:依赖项版本

时间:2018-10-25 16:10:24

标签: android dependencies

由Android Studio implementation 'com.android.support:appcompat-v7:28.0.0'突出显示的错误。

它写道:“所有com.android.support库必须使用完全相同的版本规范(混合versiosn可能导致运行时崩溃)。找到的版本28.0.0,25.2.0。示例包括com.android.support:animated- vector-drawable:28.0.0和com.android.support-support-media-compact:25.2.0)

我实际上如何知道哪个导入版本是最新的?生成等级如下:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.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'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.github.satyan:sugar:1.5'
    implementation 'com.parse:parse-android:1.13.0'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'

2 个答案:

答案 0 :(得分:0)

如果您使用的是Android Studio 3.2 您的构建gradle应该是这样的:

buil.gradle(module:app)(带有Kotlin的androidx)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sanaebadi.info.databindinginkolinworld"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

   }

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    // notice that the compiler version must be the same than our gradle version
    kapt 'androidx.databinding:databinding-compiler:3.2.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'


}

和您的buil.gradle(项目:测试)

// 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.2.0'



        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()


    }
}

task clean(type: Delete) {
    delete rootProject.buildDir

gradle-wrapper.properties

#Sun Sep 30 13:21:15 EDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

您的问题应该得到解决

答案 1 :(得分:0)

在您的依赖项中添加它:

com.android.support-support-media-compact:28.0.0

希望能解决。如果再次导致此类问题,则需要通过在gradle依赖项中添加具有版本(这次为28.0.0)的冲突库来覆盖冲突库。