Flutter image_picker 无法使用 flutter_plugin_android_lifecycle 问题

Flutter image_picker not working with flutter_plugin_android_lifecycle issue

我已按照所有步骤在全新的应用程序中实现图像选择器插件。

向 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 文档中提及。