0
我試圖設置一個應用程序,其中data
模塊是一個庫和presentation
層是實際的Android應用程序。理想情況下,我希望firebase
依賴關係僅存在於data
模塊中,但apply plugin: 'com.google.gms.google-services'
只能從presentation
模塊調用。如何在數據模塊中使用Android Kotlin Dagger 2和Firebase身份驗證?
把匕首2和火力的依賴一起給了我以下錯誤:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':presentation:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
卸下火力權威性的依賴或匕首2依賴性解決此問題。 如何在data
模塊中將這兩個庫一起使用?
我對data
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "android.arch.lifecycle:extensions:1.0.0-alpha9-1"
compile 'com.google.dagger:dagger:2.11'
kapt 'com.google.dagger:dagger-compiler:2.11'
compile 'com.google.firebase:firebase-auth:11.4.2'
}
而且爲的build.gradle呈現的build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
def configs = rootProject.extensions.getByName("ext")
compileSdkVersion configs["compileSdkVersion"]
buildToolsVersion configs["buildToolsVersion"]
defaultConfig {
applicationId configs["androidApplicationId"]
minSdkVersion configs["minSdkVersion"]
targetSdkVersion configs["targetSdkVersion"]
versionCode configs["versionCode"]
versionName configs["versionName"]
testInstrumentationRunner configs["testInstrumentationRunner"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '26.0.2'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':data')
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation("com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
這裏是頂級構建文件(如果需要)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta7'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
ext {
//Android
androidApplicationId = 'com.test.myapp'
minSdkVersion = 19
targetSdkVersion = 26
versionCode = 1
versionName = "1.0"
compileSdkVersion = 26
buildToolsVersion = "26.0.2"
//Libraries
supportLibraryVersion = '26.1.0'
//Testing
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
junitVersion = "4.12"
espressoVersion = "3.0.1"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}