无法更新Android中的任何支持库

时间:2018-07-30 09:33:07

标签: android gradle kotlin dependencies android-support-library

我决定更新项目中的依赖项。当前,所有com.android.support组件的版本均为27.0.2。例如,当我尝试将recyclerview更新为27.1.1时,我遇到了两个奇怪的错误:

  错误:[ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor无法处理此类,因为无法解决其所有依赖关系。用生成的代码检查编译错误或循环依赖性。

     

错误:android.arch.persistence.room.RoomProcessor无法处理此类,因为不是所有的依赖项都可以解决。用生成的代码检查编译错误或循环依赖性。

就像我说的那样,所有支持组件(例如设计,cardView等)都会发生这种情况。此外,当我在控制台的帮助下构建项目时,我可以看到抛出了一些异常

[更新]

以下异常不是由升级支持库版本引起的,请忽略此

Could not perform incremental compilation: Could not connect to Kotlin compile daemon
Could not connect to kotlin daemon. Using fallback strategy.
e: java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.jetbrains.kotlin.gradle.tasks.JarSearchingUtilKt.findToolsJar(jarSearchingUtil.kt:79)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$toolsJar$2.invoke(GradleCompilerEnvironment.kt:20)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$toolsJar$2.invoke(GradleCompilerEnvironment.kt:14)
        at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment.getToolsJar(GradleCompilerEnvironment.kt)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment.getCompilerFullClasspath(GradleCompilerEnvironment.kt:23)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileOutOfProcess(GradleKotlinCompilerRunner.kt:302)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:171)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:53)
        at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:127)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:108)
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:382)
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:251)
        at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:215)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Unknown Source) 

我粘贴构建gradle文件(顶部和应用程序)。

最高级别:

buildscript {
    ext.kotlin_version = '1.2.20'
    repositories {
        jcenter()
        google()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://dl.bintray.com/kotlin/kotlin-dev/"}
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.google.firebase:firebase-plugins:1.1.5' // Crash Reporting plugin

    }
}
allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://maven.google.com"} // Google's Maven repository}
        maven { url "https://jitpack.io" }
        maven { url "https://dl.bintray.com/kotlin/kotlin-dev"}
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
} 

和应用模块:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-crash'


androidExtensions {
    experimental = true
}

def mVersionName = "1.0.2"

android {

    dexOptions {
        javaMaxHeapSize "6g"
    }

    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 81
        versionName mVersionName
        // set the name of the genereted apk including version name

        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }

        // TEST (integration)
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        testHandleProfiling true
        testFunctionalTest true
    }

    packagingOptions {
        exclude 'META-INF/rxjava.properties'
        exclude 'META-INF/LICENSE'
        exclude 'LICENSE.txt'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    aaptOptions {
        // important to run code on kitkat
        additionalParameters "--no-version-vectors"
    }

    // directories like src/test/kotlin and src/androidTest/kotlin are not detected
    // as Android test locations by default (yet?),
    // we need to make Gradle and Android Studio aware of them.
    sourceSets {
        test.java.srcDirs += 'src/test/kotlin'
        androidTest.java.srcDirs += 'src/androidTest/kotlin'
    }

    // when true it won't throw an exception when referencing to Android eco system - to View/ activity etc.
    testOptions {
        unitTests.returnDefaultValues = true
    }

    // Always show the result of every unit test, even if it passes.
    testOptions.unitTests.all {
        testLogging {
            events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
        }
    }

    lintOptions {
        abortOnError false
    }
}

//Ensure Kotlin will not be used in production code.
afterEvaluate {
    android.sourceSets.all { sourceSet ->
        if (!sourceSet.name.startsWith('test') || !sourceSet.name.startsWith('androidTest')) {
            sourceSet.kotlin.setSrcDirs([])
        }
    }
}


repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "http://dl.bintray.com/glomadrian/maven" } //kod sms - edittext type
    mavenCentral()
}

kapt {
    generateStubs = true
}

dependencies {
    implementation 'com.android.support:support-v4:27.0.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Dependencies for local unit tests
    // Required for local unit tests (JUnit 4 framework)
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:2.10.0'
    // required if you want to use Mockito for unit tests
    testImplementation "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
    testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
    testImplementation 'org.amshove.kluent:kluent:1.33'
    // a library with really cool assertion semantics

    // INTEGRATION TEST
    androidTestImplementation 'org.mockito:mockito-android:2.8.47'
    // required if you want to use Mockito for Android tests
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation "com.android.support:support-annotations:27.1.1"
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs'
    })
    androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'design'
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    }
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'

    // Multidex support
    implementation 'com.android.support:multidex:1.0.3'

    // Kotlin plugin for enabling Kotlin language
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.19.3"

    // Play Services
    String playServices = '11.8.0'
    String firebase = playServices
    implementation 'com.google.android.gms:play-services-location:15.0.1'

    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-crash:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0' // Cloud Messaging

    // MAPS
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.maps.android:android-maps-utils:0.5'

    // Widgets / Views
    String supportLibrary = '27.0.2'
    implementation 'tk.zielony:carbon:0.15.0.1'
    implementation "com.android.support:appcompat-v7:$supportLibrary"
    implementation "com.android.support:design:${supportLibrary}"
    implementation "com.android.support:support-v4:${supportLibrary}"
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation "com.android.support:recyclerview-v7:${supportLibrary}"
    implementation "com.android.support:support-vector-drawable:${supportLibrary}"
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'

    // Android Architecture
    // LiveData and ViewModel
    String androidLifecycle = '1.0.0'
    String androidLifecycleExtension = '1.1.0'
    implementation "android.arch.lifecycle:common-java8:$androidLifecycleExtension"
    implementation "android.arch.lifecycle:extensions:$androidLifecycleExtension"
    annotationProcessor "android.arch.lifecycle:compiler:$androidLifecycle"
    kapt "android.arch.lifecycle:compiler:$androidLifecycle"
    implementation "android.arch.lifecycle:reactivestreams:$androidLifecycleExtension"

    // Room - DB ORM
    implementation "android.arch.persistence.room:runtime:$androidLifecycle"
    implementation "android.arch.persistence.room:rxjava2:${androidLifecycle}" // RxJava2 Support
    annotationProcessor "android.arch.persistence.room:compiler:$androidLifecycle"
    kapt "android.arch.persistence.room:compiler:$androidLifecycle"
    // Paging
    implementation "android.arch.paging:runtime:1.0.0-alpha4-1"

    // Retrofit
    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'

    String jackson = '2.9.4'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
    implementation "com.fasterxml.jackson.core:jackson-core:${jackson}"
    implementation "com.fasterxml.jackson.core:jackson-annotations:${jackson}"
    implementation "com.fasterxml.jackson.core:jackson-databind:${jackson}"
//    implementation "com.fasterxml.jackson.module:jackson-module-kotlin:${jackson}"

    // RxJava
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
    implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'

    // View injection
    String butterKnife = '8.6.0'
    implementation "com.jakewharton:butterknife:${butterKnife}"
    annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnife}"
    kapt "com.jakewharton:butterknife-compiler:${butterKnife}"

    // Injection
    String dagger = '2.16'
    implementation "com.google.dagger:dagger:${dagger}"
    implementation "com.google.dagger:dagger-android:${dagger}"
    implementation "com.google.dagger:dagger-android-support:${dagger}"
    annotationProcessor "com.google.dagger:dagger-compiler:${dagger}"
    annotationProcessor "com.google.dagger:dagger-android-processor:${dagger}"
    kapt "com.google.dagger:dagger-compiler:${dagger}"
    compileOnly 'org.glassfish:javax.annotation:10.0-b28'

    // EventBus
    implementation 'org.greenrobot:eventbus:3.1.1'

    // Bug / Crash / Memory Leaks libraries
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
        transitive = true
    }

    String leakCanary = '1.5.1'
    debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakCanary}"
    releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanary}"
    androidTestImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanary}"

    // Stetho is a sophisticated debug bridge for Android applications.
    // When enabled, developers have access to Database Inspection, and many more
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.jakewharton.timber:timber:4.6.0'
    implementation 'net.ypresto.timbertreeutils:timbertreeutils:1.0.0'

    // Support Libraries
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.github.vipulasri:timelineview:1.0.5'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.2.0'
    // letter spacing in description view (tablica rejestracyjna)
    implementation 'com.andrognito.kerningview:kerningview:1.0.0'
    // drawable with description inside
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    // view pager steps indicator (new damage)
    implementation 'com.github.rakshakhegde:stepper-indicator:2.0.0-alpha'
    // do display photo (zoom ect.)
    implementation 'com.github.chrisbanes:PhotoView:2.1.3'
    // Notification Badge
    implementation "me.leolin:ShortcutBadger:1.1.21@aar"
    // better library to handle Date()
    implementation 'net.danlew:android.joda:2.9.9.1'
    testImplementation 'joda-time:joda-time:2.9.9'

    // Picasso transformation from https://github.com/wasabeef/picasso-transformations
    implementation 'jp.wasabeef:picasso-transformations:2.2.1'
    implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'

    // better spinner from https://github.com/Lesilva/BetterSpinner
    implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'


}

kotlin {
    experimental {
        coroutines "enable"
    }
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'org.jetbrains.kotlin.android.extensions' 

1 个答案:

答案 0 :(得分:1)

我没有更新支持库,而是开始更新Kotlin。我将版本从1.2.20设置为1.2.51,然后应用kotlin kapt插件

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

并删除以下代码块:

kapt { generateStubs = true }

我也更改了匕首android处理器的方法名称

kapt "com.google.dagger:dagger-android-processor:${dagger}"

完成这些步骤后,我仍然遇到一些错误,但是这次有很多明确且易于解决的问题。问题已解决。