The task - :compileReleaseJavaWithJavac failed saying: The plugin flutter_plugin_android_lifecycle couldn't be built due to the errors:
error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
and
error: cannot find symbol
public static Lifecycle getActivityLifecycle(
^
symbol: class Lifecycle
location: class FlutterLifecycleAdapter
Here is the FlutterLifecycleAdapter.java file:
package io.flutter.embedding.engine.plugins.lifecycle;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
/** Provides a static method for extracting lifecycle objects from Flutter plugin bindings. */
public class FlutterLifecycleAdapter {
private static final String TAG = "FlutterLifecycleAdapter";
/**
* Returns the lifecycle object for the activity a plugin is bound to.
*
* <p>Returns null if the Flutter engine version does not include the lifecycle extraction code.
* (this probably means the Flutter engine version is too old).
*/
@NonNull
public static Lifecycle getActivityLifecycle(
@NonNull ActivityPluginBinding activityPluginBinding) {
HiddenLifecycleReference reference =
(HiddenLifecycleReference) activityPluginBinding.getLifecycle();
return reference.getLifecycle();
}
}
This is the first time I'm using sharedPreferences and Flutter_secure_storage and the first time I've encountered this problem. I believe error came up after I updated Android Studio. I haven't touched anything in this file. Thanks for your help in advance!