yha*_*lza 6 java android activity-lifecycle android-lifecycle flutter
任务 - :compileReleaseJavaWithJavac 失败说:由于错误,无法构建插件 flutter_plugin_android_lifecycle:
error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
Run Code Online (Sandbox Code Playgroud)
和
error: cannot find symbol
public static Lifecycle getActivityLifecycle(
^
symbol: class Lifecycle
location: class FlutterLifecycleAdapter
Run Code Online (Sandbox Code Playgroud)
这是 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();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我第一次使用 sharedPreferences 和 Flutter_secure_storage,也是我第一次遇到这个问题。我相信更新 Android Studio 后会出现错误。我没有触及此文件中的任何内容。提前感谢您的帮助!
小智 0
请按照以下步骤操作:
在gradle-wrapper.properties中添加以下代码:
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
Run Code Online (Sandbox Code Playgroud)
在gradle.properites中请检查是否添加了以下行:
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
在android/build.gradle文件中添加以下代码:
classpath 'com.android.tools.build:gradle:3.5.4'
Run Code Online (Sandbox Code Playgroud)
并在android/build.gradle中检查此版本:
compileSdkVersion 29
Run Code Online (Sandbox Code Playgroud)
请参阅此链接了解更多信息: clickhere
| 归档时间: |
|
| 查看次数: |
1062 次 |
| 最近记录: |