I want to use local_auth plugin in flutter, and it needs Android lifecycle, so i installed flutter_plugin_android_lifecycle, but i get this error with it if i try to release apk: error: package androidx.lifecycle does not exist. I tried a lot of things, but i just cannot get it to work.
''' C:\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\FlutterLifecycleAdapter.java:8: error: package androidx.lifecycle does not exist import androidx.lifecycle.Lifecycle; ^ C:\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7\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
'''
Adding implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' in build.grable plugin folder will solve the issue.
Refer https://github.com/flutter/flutter/issues/60883 for more details.
Add this in you flutter yaml dependencies
flutter_plugin_android_lifecycle: ^1.0.11
For more can visit : https://pub.dev/packages/flutter_plugin_android_lifecycle/install
This can be also due to a version gradle problem, so try to use these compatible versions in your /android/build.gradle
classpath 'com.android.tools.build:gradle:3.5.4'
you can try also:
3.3.3
3.4.3
3.5.4
3.6.4
4.0.1
This error came to me using the flutter plugin file_picker. I hope this work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With