小编Pho*_*gBM的帖子

KMM - 在项目“:shared”中找不到错误任务“embedAndSignAppleFrameworkForXcode”

我创建了一个项目来演示 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)

kotlin kotlin-multiplatform-mobile

7
推荐指数
1
解决办法
6453
查看次数

Android Compose - 如何使图像显示在状态栏下?

我刚刚开始使用 Jetpack Compose。我的应用程序有很多屏幕,它显示状态栏的颜色,这是在主题中定义的,但在某些屏幕上,我想让状态栏颜色透明,图像显示在状态栏下。

请一步步指导我。

先感谢您。

android android-jetpack-compose

6
推荐指数
1
解决办法
1万
查看次数

Android Compose - 具有像 GradientDrawable 这样的角度的自定义 LinearGradient

如何使用角度参数自定义 Brush.linearGradient(),例如 O、45、90、135...或任何其他角度?

谢谢。

android linear-gradients android-jetpack-compose

6
推荐指数
1
解决办法
3488
查看次数

Firebase 云函数捕获/处理错误

更新问题:错误: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)

请帮我。非常感谢。

error-handling node.js express google-cloud-functions

6
推荐指数
1
解决办法
819
查看次数

Android 导航组件 - 如何导航到嵌套图中的其他 startDestination

我有导航组件的问题。我有四个片段,如下图所示。

如何从片段主页导航到片段 B?

请帮帮我,谢谢。

图片:

图片

android android-jetpack

5
推荐指数
1
解决办法
254
查看次数

Android Compose - 将传统视图与 ComposeView 结合使用

我将 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

5
推荐指数
2
解决办法
219
查看次数

KMM - 如何将 Retrofit 添加到:共享模块(commonMain)

我想将 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.

请帮我。提前致谢。

kotlin kotlin-multiplatform kotlin-multiplatform-mobile

3
推荐指数
1
解决办法
3104
查看次数

Android Hilt - 两个 Fragment 之间共享 ViewModel

我在项目中使用 Jetpack Navigation 和 Hilt,并且我想仅在两个 Fragment 之间共享 ViewModel,如下所示:

  • 片段A:使用ViewModel A
  • 在片段 A 中导航到片段 B:使用 ViewModel B
  • 在片段 B 中导航到片段 C:使用 ViewModel B 的实例
  • 如果从C回到B,再回到A那么ViewModel B将会被销毁。

如何像这样配置 ViewModel B ?

更新:我找到了一种使用 Hilt Custom Scope 的方法,但我还不知道如何实现它。

提前致谢。

android dagger-hilt

3
推荐指数
1
解决办法
4727
查看次数

Android Compose - 无法使用 Modifier.align()

我使用 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)

库包含此方法 图片-1

但是,我不能称之为 图片-2

请帮我。谢谢!

android android-jetpack-compose

2
推荐指数
1
解决办法
2880
查看次数

Android Compose - 如何删除 Switch 上方和下方的空间

我有Row两个组件,TextSwitch,添加后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

2
推荐指数
1
解决办法
1114
查看次数