KotlinJvmAndroidCompilation错误归因于Gradle从Gradle 5.6.4升级到Gradle 5.6.1

时间:2020-03-04 09:49:10

标签: android-studio android-gradle-plugin

每当将Gradle从5.4.1更新到5.6.1时,都会遇到此问题。 :

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > No value has been specified for this provider.
   > KotlinJvmAndroidCompilation with name 'productionDebug' not found.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:80)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:73)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.access$600(LifecycleProjectEvaluator.java:53)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:112)
    at org.gradle.internal.Factories$1.create(Factories.java:26)

    at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
    ... 125 more


* Get more help at https://help.gradle.org

CONFIGURE FAILED in 2s

使用 -Kotlin版本v1.3.70 -Gradle v5.6.4 -Android Studio v3.6.1

请帮助。 预先感谢

1 个答案:

答案 0 :(得分:0)

我也遇到过同样的问题,事实证明,问题的原因是Fabric gradle插件(crashlytics),而不是gradle本身。

基本上,使用ext.enableCrashlytics = true结构插件在build.gradle文件中设置io.fabric.tools:gradle:1.31.2时会发生此问题。

解决方法

您必须避免将ext.enableCrashlytics显式设置为true(可以使用false)。

例如,您可以替换以下代码

def enableCrashlytics = // comes from somewhere
ext.enableCrashlytics = enableCrashlytics

作者

def enableCrashlytics = // comes from somewhere
if (!enableCrashlytics) {
    ext.enableCrashlytics = false
}

由于默认情况下启用了crashlytics,因此行为保持不变。

作为替代方案,您可以恢复使用1.31.0的效果,但效果不错,但我不建议您这样做,因为最新版本包含几个关键的bug fixes

此外,您可以考虑迁移到Firebase Crashlytics(当前为Beta版),因为Google很快就dropping support推出了Fabric,并且此问题可能无法解决。

最初回答here