Fail to run flutter with image_picker: ^0.6.7+9


I’ve got this error after adding image_picker: ^0.6.7+9 to my pubspec.yaml file and I’m already in AndroidX since my android/ file has the androidX properties, as said in this documentation ‘’.

But I get this error anyway, and after searching and trying solutions for hours, I still unable to fix it.

Here is the error message.

C:\\hosted\\flutter_plugin_android_lifecycle-1.0.9\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\ error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
C:\\hosted\\flutter_plugin_android_lifecycle-1.0.9\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\ 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


Exception: The plugin flutter_plugin_android_lifecycle could not be built due to the issue above.


I just changed ‘compileSdkVersion’ and ‘targetSdkVersion’ to 29 and worked. (before was 28)
You can find these properties in ‘android/app/build.gradle’

Answered By – Márcio Valim

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *