這是我的build.gradle文件:如何正確添加appcompat庫到android項目?
buildscript {
repositories {
mavenCentral()
// Configuration for Fabric
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
dependencies {
// 'jar' files in '/libs' folder
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
// Fabric
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true;
}
}
repositories {
mavenCentral()
// Configuration for Fabric
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 15
buildToolsVersion 22
// Define current date and time now to have the same all along the build
def currentDate = getCurrentDate()
def currentDateAndTime = getCurrentDateAndTime()
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 2.7
versionName name
minSdkVersion 15
targetSdkVersion 22
}
productFlavors {
x86 {
flavorDimension "abi"
ndk {
abiFilter "x86"
}
}
arm {
flavorDimension "abi"
ndk {
abiFilter "armeabi-v7a"
}
}
}
buildTypes {
// Configuration for release candidates
release {
// Proguard configuration
minifyEnabled true
proguardFile 'procfg.pro'
}
lintOptions {
abortOnError false
}
}
添加的依賴後,程序兼容性:
....
dependencies {
// new dependency added
compile 'com.android.support:appcompat-v7:22.0.0'
// 'jar' files in '/libs' folder
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
// Fabric
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true;
}
}
....
,我發現了以下錯誤:
AGPBI: {"kind":"ERROR","text":"Attribute \"textAllCaps\" has already been defined","sourcePath":"<dir>/colors.xml","position":{"startLine":1},"original":""}
AGPBI: {"kind":"ERROR","text":"Attribute \"track\" has already been defined","sourcePath":"<dir>/colors.xml","position":{"startLine":1},"original":""}
AGPBI: {"kind":"ERROR","text":"Attribute \"thumbTextPadding\" has already been defined","sourcePath":"<dir>/colors.xml","position":{"startLine":1},"original":""}
AGPBI: {"kind":"ERROR","text":"Attribute \"switchMinWidth\" has already been defined","sourcePath":"<dir>/colors.xml","position":{"startLine":1},"original":""}
AGPBI: {"kind":"ERROR","text":"Attribute \"switchPadding\" has already been defined","sourcePath":"<dir>/colors.xml","position":{"startLine":1},"original":""}
我已經定義了無這個值在我的color.xml文件中。我想這個問題可能與Facebook的SDK庫有關。
讓我知道你是否需要更多信息。
發佈其他依賴項 –
@GabrieleMariotti我添加了依賴關係。 – JoseF
你在使用一些罐子嗎? –