You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Kotlin DSL配置EasyLauncher插件时遇‘debug配置未找到’错误求助

解决EasyLauncher配置报错:EasyLauncherConfig with name 'debug' not found.

问题描述

我正在使用EasyLauncher库为应用图标添加标识条,采用Kotlin DSL进行配置,但应用配置时抛出错误:EasyLauncherConfig with name 'debug' not found.

配置代码如下:

plugins {
    id("kotlin-android")
    id(BuildPlugins.androidApplication)
    id("com.starter.easylauncher") version "5.1.2"
}
android {
   //...
}

dependencies {
   //...
}

easylauncher {
    buildTypes{
        getByName("debug") {
            filters(
                customRibbon(label = "Debug", ribbonColor = "#FF0000")
            )
        }
        getByName("release") {
            filters(
                customRibbon(label = "BETA", ribbonColor = "#F18357")
            )
        }

    }
}

有效解决办法

  • 确认Android构建类型已声明:EasyLauncher的配置依赖于Android模块中定义的构建类型,首先确保android块内明确存在debug和release构建类型:
android {
    buildTypes {
        debug {
            isDebuggable = true
            // 其他debug相关配置
        }
        release {
            isMinifyEnabled = true
            isShrinkResources = true
            // 其他release相关配置
        }
    }
}
  • 修正EasyLauncher配置语法:针对v5.x版本的EasyLauncher插件,Kotlin DSL需要用configure方法关联已有的构建类型,而不是直接通过getByName访问。修改后的配置代码:
easylauncher {
    configure(buildTypes.debug) {
        filters(
            customRibbon(label = "Debug", ribbonColor = "#FF0000")
        )
    }
    configure(buildTypes.release) {
        filters(
            customRibbon(label = "BETA", ribbonColor = "#F18357")
        )
    }
}
  • 清理并同步项目:执行命令./gradlew clean清理旧构建缓存,然后在Android Studio中点击"Sync Project with Gradle Files",确保新配置生效。

内容的提问来源于stack exchange,提问作者Ezzy Wachira

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 23:15:49