flutter - Flutter:AndroidManifest 找不到@xml 资源
问题描述
我创建了一个颤振应用程序,我想为其实现一个主屏幕小部件。作为第一次尝试,我正在关注本教程: https ://medium.com/@ashishgarg1998/how-to-create-home-screen-app-widgets-in-flutter-ce3458f3638e
复制代码片段后,构建时抛出以下异常:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
/Users/me/Documents/MyApp/myapp/android/app/src/main/AndroidManifest.xml:41:13-42:55: AAPT: error: resource xml/widget_info (aka de.myapp.myapp:xml/widget_info) not found.
AndroidManifest.xml 中的错误代码是:
<receiver android:name="AppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
显然,无法找到 widget_info.xml 文件。我试图只使用完整的文件路径,但编译器只会让我使用 @xml/... 表示法。我怎样才能解决这个问题?旁注:我没有任何 Android/Kotlin 经验,只有 Flutter。
解决方案
我现在实际上自己找到了解决方案。AndroidManifest.xml 文件正在寻找 @xml 资源
android/app/src/main/res
文件夹而不是
android/app/res
教程建议的文件夹。所以移动 widget_info.xml 文件就可以了。
推荐阅读
- angular - rxjs Subject 和 EventEmitter 会影响 Angular 的性能吗?
- console - Mac 上的 google d8 (v8 shell) 导航(箭头键)不导航
- javascript - vue 组件中的 d3.js - 如何将鼠标事件挂钩到元素?
- scala - 如何将元素存储在循环内的 Scala List 中?
- c# - automapper 将 typeof 对象转换为枚举
- ios - 在相同类型的 3 个单独的静态 TableViewCell 上设置内容
- php - 来自数据库的 Symfony4 数据不是 utf8 编码的
- python - 如何以编程方式访问流编辑器?
- java - 如何正确使用具有多个值的枚举
- angular - 如何在 flickr Rest API 上使用照片 url 获取照片信息?