首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:重复类: android.support.v7.appcompat.R

错误:重复类: android.support.v7.appcompat.R
EN

Stack Overflow用户
提问于 2015-03-18 11:47:13
回答 1查看 2.2K关注 0票数 0

当我试图编译我的项目时,我得到了这个错误消息"Error:(9, 14) error: duplicate class: android.support.v7.appcompat.R".,我使用的是android,我有最新的SDK包。模块的分级:

代码语言:javascript
复制
apply plugin: 'com.android.application'
android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {

        minSdkVersion 14
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {

    compile 'com.android.support:support-v4:22.0.0'
    compile files('libs/commons-codec-1.10.jar')
    compile "com.android.support:appcompat-v7:22.0.0"
}

项目的分级文件:

代码语言:javascript
复制
buildscript {
     repositories {
        jcenter()
    }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.0'
        }
    }
    allprojects {
        repositories {
            jcenter()
        } 
    }

这些是我的项目分级文件

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-18 13:01:47

将"compileOptions“移出"defaultConfig”。

我也更新了你的"buildToolsVersion“。

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    compileOptions { // <-- Moved this outside of your defaultConfig
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile files('libs/commons-codec-1.10.jar')
    compile 'com.android.support:appcompat-v7:22.0.0' // <-- brings in support-v4
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29121209

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档