androidx.lifecycle.DefaultLifecycleObserver not found

错误描述:

D:\Program Files\flutter\.pub-cache\hosted\pub.flutter-io.cn\image_picker-0.6.7+14\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerPlugin.java:15: 错误: 找不到符号
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  符号:   类 DefaultLifecycleObserver
  位置: 程序包 androidx.lifecycle
D:\Program Files\flutter\.pub-cache\hosted\pub.flutter-io.cn\image_picker-0.6.7+14\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerPlugin.java:33: 错误: 找不到符号
      implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                         ^
  符号:   类 DefaultLifecycleObserver
  位置: 类 ImagePickerPlugin

解决方案:
imagepicker插件目录android\build.gradle中添加如下行

android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 16
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    dependencies {
        implementation 'androidx.core:core:1.0.2'
        implementation 'androidx.annotation:annotation:1.0.0'
        implementation 'androidx.exifinterface:exifinterface:1.3.0'
        implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"  //新增
    }
}

来源:android - androidx.lifecycle..DefaultLifecycleObserver not found - Stack Overflow

你可能感兴趣的:(androidx.lifecycle.DefaultLifecycleObserver not found)