北极狐 3.1 RC1 - 任务 ':app:compileDebugKotlin' 执行失败

时间:2021-07-24 05:52:58

标签: android android-studio android-jetpack-compose

我只运行 RC1 版本的 artic fox,不幸的是,当我尝试运行空的 compose 活动项目时总是遇到同样的错误,这就是错误。

我不知道 1.0.0-rc01 来自哪里,当一切都更改为 rc02

> Task :app:compileDebugKotlin FAILED
w: ATTENTION!
This build uses unsafe internal compiler arguments:

-XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes

This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!

e: This version (1.0.0-rc01) of the Compose Compiler requires Kotlin version 1.5.10 but you appear to be using Kotlin version 1.5.21 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

Execution failed for task :app:compileDebugKotlin

这是 RC1 北极狐的全新副本,只是做了一些更新。我在这里错过了什么?

这是我的 build.gradle

col_wrap

:应用

from sklearn.datasets import load_boston
import math
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

X, y = load_boston(return_X_y=True)
X = pd.DataFrame(X)
y = pd.DataFrame(y)
data = pd.concat([X, y], axis=1)

y_name = 'y'
features_names = [f'feature_{i}' for i in range(1, X.shape[1]+1)]  
column_names = features_names + [y_name]
data.columns = column_names

plot_size=7
num_plots_x=5   # No. of plots in every row
num_plots_y = math.ceil(len(features_names)/num_plots_x)   # No. of plots in y direction

'''
for i in range(num_plots_y):
    start = i * num_plots_x
    end = start + num_plots_x
    sns.pairplot(x_vars=features_names[start:end], y_vars=y_name, data=data)
'''

g = sns.FacetGrid(pd.DataFrame(features_names), col=0, col_wrap=4, sharex=False)
for ax, x_var in zip(g.axes, features_names):
    sns.scatterplot(data=data, x=x_var, y=y_name, ax=ax)
g.tight_layout()

plt.savefig('figure.png')
plt.show()

4 个答案:

答案 0 :(得分:2)

您必须将 1.5.10 kotlin 与 compose 结合使用,这是目前支持的最新版本

我没有在文档中找到具体限制,但在发布页面 (https://developer.android.com/jetpack/androidx/releases/compose-compiler#declaring_dependencies) 上,他们建议使用 1.5.10。

如果您尝试使用 1.5.21 构建应用程序,则会出现错误:

e: This version (1.0.0-rc02) of the Compose Compiler requires Kotlin version 1.5.10 but you appear to be using Kotlin version 1.5.21 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

我尝试用 suppressKotlinVersionCompatibilityCheck 构建它,在我的例子中它失败了 java.lang.InstantiationError: org.jetbrains.kotlin.ir.util.TypeTranslator

我认为这与新的 kotlin 后端有关,该后端在最近的版本中获得了许多更新,看起来 compose 非常依赖它。

答案 1 :(得分:2)

将项目级 build.gradle 文件中的第二个依赖项更改为

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"

答案 2 :(得分:1)

将项目的 Kotlin 版本更改为 1.5.21 到 1.5.10。因为 Jetpack compose 1.0.0-rc1 或 rc2 版本只适用于 Kotlin 1.5.10 版本。

以前:

<块引用>

1.5.21

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

立即行动:

<块引用>

1.5.10

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"

答案 3 :(得分:0)

Compose 从 1.0.1 开始支持 Kotlin 1.5.21