Flutter编译报错::dash_bubble:compileDebugKotlin任务执行失败
Flutter编译失败:dash_bubble插件出现Unresolved reference错误
我的android/build.gradle配置
buildscript { ext.kotlin_version = '2.1.10' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.15' } } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { afterEvaluate { project -> // check only for "com.android.library" to not modify // your "app" subproject. All plugins will have "com.android.library" plugin, and only your app "com.android.application" // Change your application's namespace in main build.gradle and in main android block. if (project.plugins.hasPlugin("com.android.library")) { project.android { if (namespace == null) { namespace project.group } } } } } subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir }
执行flutter run --debug时的错误日志
PS C:\Users\useru\Downloads\EDITED\flutter_driver> flutter run --debug Launching lib\main.dart on sdk gphone x86 64 in debug mode... Checking the license for package Android SDK Platform 30 in C:\Users\useru\AppData\Local\Android\sdk\licenses License for package Android SDK Platform 30 accepted. Preparing "Install Android SDK Platform 30 (revision 3)". "Install Android SDK Platform 30 (revision 3)" ready. Installing Android SDK Platform 30 in C:\Users\useru\AppData\Local\Android\sdk\platforms\android-30 "Install Android SDK Platform 30 (revision 3)" complete. "Install Android SDK Platform 30 (revision 3)" finished. Note: C:\Users\useru\AppData\Local\Pub\Cache\hosted\pub.dev\bubble_head-0.0.4\android\src\main\java\com\dsaved\bubblehead\bubble\BubbleHeadService.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\useru\AppData\Local\Pub\Cache\hosted\pub.dev\device_apps-2.2.0\android\src\main\java\fr\g123k\deviceapps\DeviceAppsPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. e: file:///C:/Users/useru/AppData/Local/Pub/Cache/hosted/pub.dev/dash_bubble-2.0.0/android/src/main/kotlin/dev/moaz/dash_bubble/src/BubbleService.kt:65:24 Unresolved reference 'ic_close_bubble'. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':dash_bubble:compileDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 3m 44s Running Gradle task 'assembleDebug'... 226,0s Error: Gradle task assembleDebug failed with exit code 1 PS C:\Users\useru\Downloads\EDITED\flutter_driver>
解决方案
错误核心是dash_bubble-2.0.0插件中缺失ic_close_bubble资源文件,或资源引用路径错误,可按以下步骤修复:
- 清理缓存:执行命令清理Flutter和Gradle缓存
flutter clean cd android gradlew clean cd .. - 重新拉取插件:找到pub缓存中的
dash_bubble-2.0.0目录(路径:C:\Users\useru\AppData\Local\Pub\Cache\hosted\pub.dev\dash_bubble-2.0.0),删除该文件夹后执行:flutter pub get - 更换插件版本:修改
pubspec.yaml中dash_bubble的版本号(比如降级到1.1.0或升级到最新稳定版),再执行flutter pub get重新获取依赖 - 手动修复插件资源:若熟悉Android开发,可打开报错的
BubbleService.kt文件,修正ic_close_bubble的引用路径,或手动添加对应图标资源到插件的res/drawable目录下
内容的提问来源于stack exchange,提问作者user22111293
相关产品推荐
相关产品推荐

