我正在开发一个旧项目,它使用两个模块并将它们添加到根项目中,其中一个模块在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')
}
而app项目有这个
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 values文件夹并更改showdivider的名称但是造成其他问题。
答案 0 :(得分:1)
首先,删除String fileName = "c://SomeFile.txt";
String stringToSearch = "dummy";
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
// Find first
Optional<String> lineHavingTarget = stream.filter(l -> l.contains(stringToSearch)).findFirst();
// search all
stream.filter(l -> l.contains(stringToSearch)).forEach(System.out::println);
// do whatever
} catch (IOException e) {
// log exception
}
个文件中的这些依赖项。它们以Eclipse的风格添加并导致冲突。
build.gradle
仅在compile files('libs/android-support-v7-appcompat.jar')
compile project(':androidsupportv7appcompat')
文件的support-v7
下添加此行,才能使用dependencies
库替换它们。
build.gradle
另外,您应该考虑替换它,因为我认为它已被弃用。
compile 'com.android.support:support-v7:21.0.0'
最后,你设置minSdk是7,所以你甚至不需要这种依赖。所以,你可以删除它。
compile(project(":xxxlibraryForActionBar")) {
exclude module: 'support-v4'
}