我创建了一个项目来演示 Kotlin Multiplatform Mobile。我在 Android 和 iOS 两种设备上成功构建并运行了它。之后,我在 iOS 上重新运行了该项目。它有一个错误。
> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature. See: https://kotlinlang.org/docs/reference/evolution/components-stability.html. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
FAILURE: Build failed with an exception.
* What went wrong:
Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more …Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用 Jetpack Compose。我的应用程序有很多屏幕,它显示状态栏的颜色,这是在主题中定义的,但在某些屏幕上,我想让状态栏颜色透明,图像显示在状态栏下。
请一步步指导我。
先感谢您。
如何使用角度参数自定义 Brush.linearGradient(),例如 O、45、90、135...或任何其他角度?
谢谢。
更新问题:错误:TypeError:res.json 不是函数
我将 Firebase Cloud Functions 与 Express 应用程序结合使用。我使用中间件来处理错误,但它不起作用。使用时如何捕获/处理错误throw new Error()?
我的代码如下:
app.get('/test', (req, res) => {
throw new Error('this is error')
})
function errorHandler(err, req, res, next) {
res.json({error: err.message}) // error here
}
app.use(errorHandler)
exports.api = functions.https.onRequest(app)
Run Code Online (Sandbox Code Playgroud)
请帮我。非常感谢。
我有导航组件的问题。我有四个片段,如下图所示。
如何从片段主页导航到片段 B?
请帮帮我,谢谢。
图片:

我将 Compose 与现有片段一起使用。我在 xml 中的结构
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<ImageView />
<MaterialToolbar />
</CollapsingToolbarLayout>
</AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.compose.ui.platform.ComposeView
android:id="@+id/composeContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.NestedScrollView>
</CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
在 ComposeView 中,我使用 LazyColum,它因日志而崩溃
java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like ScrollableContainer and LazyColumn is not allowed. If you want to add a header before the list of items please take a look on LazyColumn component which has a DSL api which allows to first add a header via item() function and then …Run Code Online (Sandbox Code Playgroud) android android-collapsingtoolbarlayout android-jetpack-compose
我想将 Retrofit 添加到 :shared 模块 (commonMain) 中。
sourceSets["commonMain"].dependencies {
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
}
Run Code Online (Sandbox Code Playgroud)
但在commonMain我看不到 Retrofit 类。在androidMain我可以看到它。那是一种魔法。我没有将 Retrofit 添加到androidMain.
请帮我。提前致谢。
我在项目中使用 Jetpack Navigation 和 Hilt,并且我想仅在两个 Fragment 之间共享 ViewModel,如下所示:
如何像这样配置 ViewModel B ?
更新:我找到了一种使用 Hilt Custom Scope 的方法,但我还不知道如何实现它。
提前致谢。
我使用 Compose 版本 1.0.0-beta06,无法调用Modifier.align()方法
构建.gradle
// Compose
implementation 'androidx.compose.ui:ui:1.0.0-beta06'
implementation 'androidx.compose.ui:ui-tooling:1.0.0-beta06'
implementation 'androidx.compose.foundation:foundation:1.0.0-beta06'
implementation 'androidx.compose.material:material:1.0.0-beta06'
implementation 'androidx.compose.material:material-icons-core:1.0.0-beta06'
implementation 'androidx.compose.material:material-icons-extended:1.0.0-beta06'
implementation 'androidx.activity:activity-compose:1.3.0-alpha07'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04'
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta06'
implementation 'androidx.compose.runtime:runtime-rxjava2:1.0.0-beta06'
// Compose Accompanist
implementation 'com.google.accompanist:accompanist-coil:0.9.1'
implementation 'com.google.accompanist:accompanist-pager:0.9.1'
implementation 'com.google.accompanist:accompanist-pager-indicators:0.9.1'
implementation 'com.google.accompanist:accompanist-systemuicontroller:0.9.1'
// Compose other libs
implementation("androidx.compose.ui:ui-util:1.0.0-beta06")
Run Code Online (Sandbox Code Playgroud)
请帮我。谢谢!
我有Row两个组件,Text和Switch,添加后Switch,我看到上面和下面的空间。我希望 的高度Switch适合 UI 高度。
我使用padding(0.dp)但它不起作用。
如何删除它?
这是我的代码:
Row(
modifier = Modifier
.fillMaxWidth()
.background(color = Color.Red),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "This is a text",
modifier = Modifier.background(color = Color.Yellow)
)
Switch(
checked = false,
onCheckedChange = {},
modifier = Modifier
.padding(0.dp)
.background(color = Color.Blue)
)
}
Run Code Online (Sandbox Code Playgroud)
android android-jetpack-compose jetpack-compose-switch android-compose-switch
android ×7
kotlin ×2
kotlin-multiplatform-mobile ×2
android-collapsingtoolbarlayout ×1
dagger-hilt ×1
express ×1
node.js ×1