我想在同一个项目中使用一些Google Play服务和一些额外的库。我的app/build.gradle
文件如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "bahir.com.myapplication"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// !!! problematic code !!!
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
compile 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.92'
}
apply plugin: 'com.google.gms.google-services'
我的root/build.gradle
文件如下所示:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
如果我删除所有3个Google Play服务库 - 它运行良好,或者我必须删除此代码:
// !!! problematic code !!!
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
当然:
compile 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.92'
要成功构建,我认为冲突是app/build.gradle
中有问题的代码,所以有没有办法为单个lirary声明repositories
,在我的情况下为compile 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.92'
???
答案 0 :(得分:0)
使用新插件:
classpath 'com.google.gms:google-services:4.0.1'
答案 1 :(得分:0)
compile("com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.92") {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'design'
}