【发布时间】:2017-05-08 01:49:43
【问题描述】:
我正在开发一个旧项目,它使用两个模块并将它们添加到根项目中,其中一个模块在 build.gradle 中有此设置
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '21.1.0'
defaultConfig {
minSdkVersion 7
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile files('libs/android-support-v7-appcompat.jar')
}
而应用项目有这个
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion '22'
lintOptions {
checkReleaseBuilds false
abortOnError false
}
defaultConfig {
minSdkVersion 13
targetSdkVersion 22
applicationId 'xxxxxx'
versionCode xxx
versionName 'xxx'
multiDexEnabled false
}
signingConfigs {
release {
storeFile file("xxxx")
storePassword "xxx"
keyAlias "xxx"
keyPassword "xxxx"
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = true
signingConfig signingConfigs.release
}
debug {
minifyEnabled true
ext.enableCrashlytics = true
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':androidsupportv7appcompat')
compile(project(":xxxlibraryForActionBar")) {
exclude module: 'support-v4'
}
compile files('libs/commons-io-1.3.2.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.volley:volley:1.0.0'
}
我的根项目有
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当我更改(在 app build.gradle 中)编译 sdk 到 23 并将构建工具到 23.0.1 并添加 编译'com.android.support:design:23.4.0',它给我的错误是已经定义了一些属性,我知道它与两个都声明相同字段但添加的库之一冲突如何解决。
Error:(268) Attribute "windowActionBar" has already been defined
Error:(268) Attribute "windowActionBarOverlay" has already been defined
Error:(268) Attribute "windowFixedWidthMajor" has already been defined
Error:(268) Attribute "windowFixedWidthMinor" has already been defined
Error:(268) Attribute "windowFixedHeightMinor" has already been defined
Error:(268) Attribute "actionBarTabStyle" has already been defined
Error:(268) Attribute "windowFixedHeightMajor" has already been defined
虽然在将所有内容更新到新版本之后,我现在得到了
属性 showDivider 已经存在,我发现当 android 合并所有值文件时它是冲突的但找不到任何解决方案,我试图进入 appcompactv7 值文件夹并更改 showdivider 的名称,但这会创建其他问题。
【问题讨论】:
-
你提到的后面的
build.gradle文件是root项目级还是app模块级?我认为它在app模块级别。 -
你说得对,它是在应用程序模块级别,我有 3 个,我将在一秒钟内用我的根 build.gradle 更新它。
-
我已经编辑了这个问题,并提供了更多细节,你知道我该如何解决这个冲突吗?
-
我在下面写下我的答案。我们不应使用任何通常会导致冲突的支持库 .jar 文件。改为添加库依赖项。
-
我正在试一试,我曾怀疑过,但由于我不是专家,需要指导,专家意见会让你知道它是如何进行的。谢谢
标签: android android-design-library