image - Flutter image_picker 不适用于flutter_plugin_android_lifecycle 问题
问题描述
我已经按照所有步骤在一个全新的应用程序中实现了图像选择器插件。
向 pubspec.yaml 添加了依赖项
dependencies:
image_picker: 0.6.2+3
添加到清单中
android:requestLegacyExternalStorage="true"
遵循示例代码,但我得到的是这个错误..
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
../project/android/app/src/main/AndroidManifest.xml:9:5-53:19: AAPT: error: attribute android:requestLegacyExternalStorage not found.
和
/Users/.../Documents/_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.8/android/src/main/java/io/flutter/embedding/engine/plugins/lifecycle/FlutterLifecycleAdapter.java:8: error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
^
/Users/.../Documents/_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.8/android/src/main/java/io/flutter/embedding/engine/plugins/lifecycle/FlutterLifecycleAdapter.java:22: error: cannot find symbol
public static Lifecycle getActivityLifecycle(
^
symbol: class Lifecycle
location: class FlutterLifecycleAdapter
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for 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 1s
Exception: The plugin flutter_plugin_android_lifecycle could not be built due to the issue above.
我在这里做错了什么!
解决方案
经过深入搜索,我得到了解决这个问题的线索。该应用程序需要针对 SDK 29 进行编译,这是最新的 buildTool,包括 Android 10 中引入的最新更改。
内部应用程序级别build.gradle
文件
// ...
android {
compileSdkVersion 29
// ....
defaultConfig {
targetSdkVersion 29
//...
我认为这应该在image_picker
文档中提及。
推荐阅读
- excel - 使用VBA将excel公式分配给变量
- twitter-bootstrap - 变换动画不适用于引导轮播中的第一张幻灯片
- javascript - 单击功能应用于具有相同类的所有 div
- .net - 迁移到较新的框架版本是否可以解决安全问题
- javascript - 从循环中停止逐行javascript动画
- microsoft-graph-api - 通过 MS Graph API 返回用户的employeeId
- json - Mule 3.9 Dataweave 从整数中删除 .00
- c++ - Xerces-C 使用硬编码的 xsd 验证 xml
- nginx - 缓存在使用 proxy_cache 的 nginx 中不起作用。
- c# - 向 USB/以太网连接设备发送多个命令