小编Ale*_*lex的帖子

执行 org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException 时发生故障(无错误消息)

Android studio 报错:

Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
   > java.lang.reflect.InvocationTargetException (no error message)
Run Code Online (Sandbox Code Playgroud)

我想在我的项目 Kotlin Coroutines 中添加并将其与 Room 数据库一起使用。但是在添加了所有库之后,我收到了这个错误。这是来自编译器的所有信息。

我已经确定,这是因为注释@Database。如果我删除此注释,则不会出现错误,但 Room 也无法正常工作。

我的gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
//apply plugin: 'androidx.navigation.safeargs'

kotlin {
    experimental {
        coroutines 'enable'
    }
}

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.bestcred.coursetthree"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        //vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-room kotlin-coroutines

63
推荐指数
8
解决办法
3万
查看次数

com.android.tools.r8.CompilationFailedException:编译未能完成,位置:Lcom/facebook/login/DefaultAudience$EnumUnboxingLocalUtility;

将 kotlin 版本 ( ext.kotlin_version ) 更新到1.6.10后,出现一些错误:

com.android.tools.r8.internal.E00: Unexpected type in conversion to primitive: OBJECT

Execution failed for task ':app:minifyReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: Lcom/facebook/login/DefaultAudience$EnumUnboxingLocalUtility;getNativeProtocolAudience(I)Ljava/lang/String;, origin: ..\.gradle\caches\transforms-3\57102c4e3d32396b86898e5ca0dd620d\transformed\jetified-facebook-core-7.1.0-runtime.jar:com/facebook/login/DefaultAudience.class
Run Code Online (Sandbox Code Playgroud)

如果我在build.gradle (:app)中使用选项minifyEnabled true 和生成签名包,就会发生这种情况。如果我使用旧的ext.kotlin_version(例如 1.5.0),则不会出现此错误。

我认为,如果我在proguard-rules.pro中使用正确的规则,我可以解决这个问题。

android facebook proguard gradle android-r8

8
推荐指数
2
解决办法
3万
查看次数

Jetpack 撰写。selectedContentColor 和 unselectedContentColor 在 BottomNavigationItem 中不起作用

我有代码:

@Composable
fun BottomNavigationBar(navController: NavController) {
    val items = listOf(
        BottomNavigationItem.One,
        BottomNavigationItem.Two,
        BottomNavigationItem.Three,
        BottomNavigationItem.Four,
        BottomNavigationItem.Five
    )
    BottomNavigation(
        backgroundColor = colorResource(id = R.color.teal_700),
        contentColor = Color.White
    ) {
        val navBackStackEntry by navController.currentBackStackEntryAsState()
        val currentRoute = navBackStackEntry?.destination?.route
        items.forEach { item ->
            BottomNavigationItem(
                icon = { Icon(painterResource(id = item.icon), contentDescription = item.title) },
                label = { Text(text = item.title) },
                selectedContentColor = Color.White,
                unselectedContentColor = Color.White.copy(0.4f),
                alwaysShowLabel = true,
                selected = currentRoute == item.route,
                onClick = {
                    navController.navigate(item.route) {
                        navController.graph.startDestinationRoute?.let { route -> …
Run Code Online (Sandbox Code Playgroud)

navigation android-jetpack-compose bottom-navigation-bar

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