使用Jetpack Compose Media3遇资源未找到错误,求修复帮助
修复Jetpack Compose Media3中notification_channel资源找不到的问题
你遇到的错误是因为项目中缺少对应的字符串资源,按以下步骤解决:
确认
res/values/strings.xml(或对应多语言的values子目录)中存在指定的字符串资源,添加如下内容:<string name="notification_channel">媒体播放通知渠道</string> <string name="notification_channel_description">用于展示媒体播放状态的通知渠道</string>注意资源名称必须和代码中引用的
notification_channel、notification_channel_description完全一致,大小写敏感。同步项目资源:点击Android Studio顶部菜单栏的
File -> Sync Project with Gradle Files,确保资源被正确识别并编译。清理重建项目:执行
Build -> Clean Project后再执行Build -> Rebuild Project,清除可能存在的资源缓存问题。检查代码拼写:确认代码中
R.string.notification_channel和R.string.notification_channel_description的拼写没有错误,避免因笔误导致资源找不到。
内容的提问来源于stack exchange,提问作者H M Z
相关产品推荐
相关产品推荐

