更新到 Android Studio Arctic Fox 后,我无法选择任何已安装的主题。无效的缓存和重新启动没有帮助;) 重新安装主题仍然没有解决这个问题。
我在稳定频道上使用 Toolbox 将 AS 4.2 更新到了北极狐。我赢了 10。
也许有人知道如何解决这个问题?
我可以选择什么:
我安装了什么:
android intellij-plugin android-studio android-studio-plugin android-studio-arctic-fox
我有一个大项目,我决定向其中添加 jetpack compose。首先,我准备了一个包含一些@Composable组件的独立项目,一切正常。然后,在编译期间向我的项目添加源和 preper 依赖项后,我开始收到此错误:
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: C:/Users/.../CatalogScreen.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:55)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:41)
...
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:CatalogScreen visibility:public modality:FINAL <> () returnType:kotlin.Unit
annotations:
Composable
BLOCK_BODY
VAR PROPERTY_DELEGATE name:currentTab$delegate type:androidx.compose.runtime.MutableState<kotlin.Int> [val]
CALL 'public final fun remember <T> (calculation: @[DisallowComposableCalls] kotlin.Function0<T of androidx.compose.runtime.ComposablesKt.remember>): T of androidx.compose.runtime.ComposablesKt.remember [inline] declared in androidx.compose.runtime.ComposablesKt' type=androidx.compose.runtime.MutableState<kotlin.Int> …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
@Composable
fun SomeDialog() {
Dialog(onDismissRequest = { }, properties = DialogProperties()) {
....
}
}
@Preview(showBackground = true)
@Composable
fun SomeDialogPreview() {
MyTherapyPreviewTheme {
Scaffold {
SomeDialog()
}
}
}
Run Code Online (Sandbox Code Playgroud)
我预计此预览将生成类似于其他可组合函数的预览,但我只在预览中看到一个白色矩形(纯脚手架)。
如何以正确的方式生成对话框预览?或者也许我只能在单独的函数中预览对话框的内容?
我想设置我的渐变背景TopAppBar:
我的代码:
TopAppBar(
modifier = Modifier.background(
Brush.horizontalGradient(
colors = listOf(
Color.Red,
Color.Green
)
)
),
title = { Text("UI Components") },
backgroundColor = Color.Transparent
)
Run Code Online (Sandbox Code Playgroud)
结果:
我找到了这篇文章:Jetpack Compose Button withgradientbackground? 对于按钮 - 所以我通过修改器设置backgroundColor透明和自定义背景。可悲的是,就我而言,文本周围有一个额外的阴影,我不知道如何删除。我应该更改什么,或者也许 TopAppBar 不适合使用渐变,我应该编写一些完全自定义的内容?
在将构建脚本从 groovy 迁移到 kotlin 期间,我遇到了排除构建变体的问题。
在 groovy 中这非常简单:
android {
variantFilter { variant ->
if (variant.name == "lorempisum") {
setIgnore(true)
}
}
}
Run Code Online (Sandbox Code Playgroud)
但在 kotlin 中类似的事情不起作用。在android studio中似乎没问题,但在编译过程中它抛出Unresolved reference: isIgnore
android {
variantFilter {
if (buildType.name == "lorempisum") {
isIgnore = true
}
}
}
Run Code Online (Sandbox Code Playgroud)
从另一面报告Unresolved reference: setIgnore,但在编译期间有效
android {
variantFilter {
if (buildType.name == "lorempisum") {
this.setIgnore(true)
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人知道如何以正确的方式做到这一点吗?
我正在使用 kotlin 1.3.72、android studio 4.0.1 和 gradle 6.5.1
- - 编辑 - -
我修复了第二个块中的示例ignore-> …
要在我们的 android-library 模块中启用脱糖,我们必须将其放入build.gradle:
android {
compileOptions {
coreLibraryDesugaringEnabled true
}
}
Run Code Online (Sandbox Code Playgroud)
但是我们所有的脚本都迁移到了 gradle kotlin dsl,所以问题出现build.gradle.kts在所有三个方面:
android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
Run Code Online (Sandbox Code Playgroud)
configure<BaseExtension> {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
Run Code Online (Sandbox Code Playgroud)
android {
if (this is com.android.build.api.dsl.LibraryExtension<*, *, *, *, *, *, *, *, *, *, *>) {
buildFeatures.viewBinding = true
}
}
Run Code Online (Sandbox Code Playgroud)
每次它抛出Unresolved reference: isCoreLibraryDesugaringEnabled.
有人知道如何解决这个问题吗?