【问题标题】:Android Appcompat-v7 ErrorAndroid Appcompat-v7 错误
【发布时间】:2017-04-19 16:34:17
【问题描述】:

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

编译'com.android.support:appcompat-v7:23.4.0'

有错误

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 24.0.0、23.4.0。示例包括 com.android.support:support-v4:24.0.0com.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 的屏幕截图:

【问题讨论】:

    标签: android android-studio build.gradle android-appcompat


    【解决方案1】:

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

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

    【讨论】:

    • 我喜欢这样然后它告诉 buildToolsVersion "24.0.0" 太旧并且想要更新 "25.0.0" 我这样做了但问题是一样的
    【解决方案2】:

    你正在使用

    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'
    

    谢谢你:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多