Android Appcompat-v7 错误

Android Appcompat-v7 Error

我正在使用 android studio 2.3.1,在 android build.gradle

compile 'com.android.support:appcompat-v7:23.4.0'

有错误

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 24.0.0, 23.4.0. Examples include com.android.support:support-v4:24.0.0 and com.android.support:animated-vector-drawable:23.4.0

这是我的build.gradle

apply plugin: 'com.android.application'   

android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
    applicationId "com.wsolus.chathuranga.simplifya"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 22
    versionName "2.0.1"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
} } dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
  compile('org.apache.httpcomponents:httpmime:4.3') {
    exclude module: "httpclient"
}
  compile 'com.android.support:appcompat-v7:23.4.0'
  compile 'com.android.support:design:23.4.0'
  compile 'com.android.support:support-v4:23.4.0'

}

请帮帮我 谢谢

这是 gradle:

的屏幕截图

像这样更改您的 gradle 文件,然后转到 文件 -> 使缓存无效并重新启动

apply plugin: 'com.android.application'   

android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
    applicationId "com.wsolus.chathuranga.simplifya"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 22
    versionName "2.0.1"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
} } dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
  compile('org.apache.httpcomponents:httpmime:4.3') {
    exclude module: "httpclient"
}
  compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:palette-v7:24.2.0'

}

您目前正在使用

compileSdkVersion 23
buildToolsVersion '25.0.0'

首先将您的CompileSDK构建工具版本更改为

compileSdkVersion 25
buildToolsVersion '25.0.2'

并将您的依赖性更改为 注释您的 appcompat 依赖项并将版本升级到您的其他依赖项。 我也遇到了这个错误。这对我有用。

   //compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'

谢谢你:)