使用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
相关产品推荐
相关产品推荐

