gpt4 book ai didi

java - 无法构建插件flutter_plugin_android_lifecycle

转载 作者:行者123 更新时间:2023-12-04 12:02:45 27 4
gpt4 key购买 nike

任务 - :compileReleaseJavaWithJavac 失败说:
由于错误,无法构建插件flutter_plugin_android_lifecycle:

error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;



error: cannot find symbol
public static Lifecycle getActivityLifecycle(
^
symbol: class Lifecycle
location: class FlutterLifecycleAdapter

这是 FlutterLifecycleAdapter.java 文件:

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();
}
}

这是我第一次使用 sharedPreferences 和 Flutter_secure_storage,也是我第一次遇到这个问题。
我相信更新 Android Studio 后出现错误。
我没有触及这个文件中的任何内容。
提前感谢您的帮助!

最佳答案

请按照以下步骤操作:
gradle-wrapper.properties 在下面添加这些代码:

distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
enter image description here
gradle.properites 请检查以下行是否已添加:
android.useAndroidX=true
android.enableJetifier=true
enter image description here
安卓/build.gradle 文件添加以下代码:
classpath 'com.android.tools.build:gradle:3.5.4'
enter image description here
并在 中查看此版本安卓/build.gradle :
compileSdkVersion 29
enter image description here
请参阅此链接了解更多信息:
clickhere

关于java - 无法构建插件flutter_plugin_android_lifecycle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61568995/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com