我想在android studio中使用view pager指标库。因为它可用于maven而不是gradle项目,所以我在android studio中添加库文件夹并将其包含在app build.gradle文件中。问题出现了,当我编译项目因此它不会编译,因为app和库gradle文件都使用android-support-v4.jar文件。我需要知道如何在android studio中使用该库。
settings.gradle
include ':app'
include ':library'
include ':sample'
应用程序/的build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':library')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
library.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
android {
sourceSets {
main {
java.srcDirs = ['src']
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
}
}
compileSdkVersion 19
buildToolsVersion '19.0.3'
}
dependencies {
compile files('libs/android-support-v4.jar')
// compile 'com.android.support:support-v4:19.+'
// compile fileTree(dir: 'libs', include: ['*.jar'])
}
答案 0 :(得分:1)
不要像在库的 build.gradle 文件中那样,通过向jar文件添加直接依赖项来包含支持库。如果您通过Maven坐标样式包含它到处包含它,就像您注释掉的行一样,构建系统不会遇到重复问题:
dependencies {
compile 'com.android.support:support-v4:19.+'
}
答案 1 :(得分:0)
include ':libs:ViewPagerIndicator-Library'
compile project(':libs:ViewPagerIndicator-Library')