我在更新应用使用的外部库时遇到了一些问题。以下是gradle文件:
Project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
daggerVersion = "2.13"
supportVersion = "27.1.1"
}
应用程序build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.myapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:cardview-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"
implementation "com.android.support:animated-vector-drawable:$supportVersion"
implementation "com.android.support:support-fragment:$supportVersion"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-analytics:12.0.1'
// implementation 'com.android.support:multidex:1.0.3'
// Google Sign In SDK (only required for Google Sign In)
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.hannesdorfmann.mosby3:mvp-lce:3.0.4'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
kapt 'com.github.bumptech.glide:compiler:4.6.1'
// Firebase UI
// Used in FirebaseUIActivity. The FirebaseUI-Android library has a minSdk level of 16
// so this library is only included in the minSdkJellybean variant.
implementation 'com.firebaseui:firebase-ui-auth:3.2.1'
// Facebook Android SDK (only required for Facebook Login)
// Used in FacebookLoginActivity. This is only compiled into the minSdkJellybean variant of this
// app. You can build a 'minSdkGingerbread' variant to test on devices with 9 <= SDK <= 15.
implementation 'com.facebook.android:facebook-login:4.31.0'
implementation "com.android.support:customtabs:$supportVersion"
// Twitter Android SDK (only required for Twitter Login)
// implementation('com.twitter.sdk.android:twitter-core:3.2.0@aar') {
// transitive = true
// }
// implementation('com.twitter.sdk.android:twitter:3.2.0@aar') {
// transitive = true
// }
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// Dagger
implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion"
implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
// Room
implementation "android.arch.persistence.room:runtime:1.0.0"
kapt "android.arch.persistence.room:compiler:1.0.0"
implementation "android.arch.lifecycle:common-java8:1.1.1"
// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
// compile 'io.reactivex.rxjava2:rxkotlin:2.2.0'
// RxFirebase
implementation('com.github.b3er.rxfirebase:firebase-database:11.2.0') {
transitive = false
}
// // PhotoView
// implementation 'com.github.chrisbanes:PhotoView:2.1.3'
// ucrop
// implementation 'com.github.yalantis:ucrop:2.2.2'
}
apply plugin: 'com.google.gms.google-services'
但是当我尝试运行应用程序时,我收到以下错误:
Executing tasks: [:app:assembleDebug]
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.github.bumptech.glide:compiler:4.6.1'.
:app:buildInfoDebugLoader
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mainApkListPersistenceDebug UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: /Users/joan/Development/myapp/git/myapp-android/app/google-services.json
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:kaptGenerateStubsDebugKotlin
:app:kaptDebugKotlin
w: Note: [1] Wrote GeneratedAppGlideModule with: []
w: warning: Supported source version 'RELEASE_7' from annotation processor 'org.jetbrains.kotlin.kapt3.ProcessorWrapper' less than -source '1.8'
w: /Users/joan/Development/myapp/git/myapp-android/app/build/tmp/kapt3/stubs/debug/com/myapp/model/ApplicationDatabase.java:7: warning: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.
public abstract class ApplicationDatabase extends android.arch.persistence.room.RoomDatabase {
^
:app:compileDebugKotlin
:app:prepareLintJar UP-TO-DATE
:app:generateDebugSources
:app:javaPreCompileDebug
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileDebugJavaWithJavac
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:packageInstantRunResourcesDebug
:app:validateSigningDebug
:app:processInstantRunDebugResourcesApk
:app:checkManifestChangesDebug
:app:transformClassesWithStackFramesFixerForDebug
:app:transformClassesWithDesugarForDebug
:app:transformClassesWithExtractJarsForDebug
:app:transformClassesWithInstantRunVerifierForDebug
:app:transformClassesWithDependencyCheckerForDebug
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug
:app:transformNativeLibsAndResourcesWithJavaResourcesVerifierForDebug
:app:transformClassesWithInstantRunForDebug
:app:transformClassesEnhancedWithInstantReloadDexForDebug
:app:incrementalDebugTasks
:app:preColdswapDebug
:app:fastDeployDebugExtractor
:app:generateDebugInstantRunAppInfo
:app:transformClassesWithInstantRunSlicerForDebug
:app:transformClassesWithDexBuilderForDebug
AGPBI: {"kind":"error","text":"Program type already present: android.arch.lifecycle.LiveData$1","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
:app:buildInfoGeneratorDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/0.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/1.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/2.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/3.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/4.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/5.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/6.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/7.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/8.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/9.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/10.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/11.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/12.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/13.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/14.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/15.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/16.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/17.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/18.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/19.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/20.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/21.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/22.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/23.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/24.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/25.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/26.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/27.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/28.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/29.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/30.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/31.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/32.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/33.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/34.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/35.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/36.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/37.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/38.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/39.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/40.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/41.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/42.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/43.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/44.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/45.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/46.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/47.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/48.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/49.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/50.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/51.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/52.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/53.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/54.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/55.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/56.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/57.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/58.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/59.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/60.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/61.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/62.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/63.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/64.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/65.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/66.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/67.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/68.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/69.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/70.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/71.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/72.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/73.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/74.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/75.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/76.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/77.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/78.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/79.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/80.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/81.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/82.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/83.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/84.jar, /Users/joan/Development/myapp/git/myapp-android/app/build/intermediates/transforms/dexBuilder/debug/85.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 22s
45 actionable tasks: 34 executed, 11 up-to-date
但是如果我将supportVersion更改为27.0.2,一切正常,直到我添加另一个库(实现'com.github.yalantis:ucrop:2.2.2'),然后我遇到同样的问题。看起来每个库都使用我使用的其他库的不同版本,但我不知道如何解决这个问题。有什么帮助吗?