【问题标题】:Unresolved reference: embedding and Unresolved reference: FlutterActivity in MainActivity.kt未解析的引用:嵌入和未解析的引用:MainActivity.kt 中的 FlutterActivity
【发布时间】:2021-06-17 13:46:26
【问题描述】:

我的 Flutter 应用程序一直运行良好,直到我停止构建成功

android/app/src/main/kotlin/com/apps/myapp/MainActivity.kt文件

package com.apps.myapp

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
 
}

控制台

Built build/app/outputs/repo.
Building plugin workmanager...
✓ Built build/app/outputs/repo.
e: /home/apps/myapp/android/app/src/main/kotlin/com/apps/myapp/MainActivity.kt: (3, 19): Unresolved reference: embedding
e: /home/apps/myapp/android/app/src/main/kotlin/com/apps/myapp/MainActivity.kt: (5, 21): Unresolved reference: FlutterActivity

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more 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.

请帮助解决此问题!谢谢。

【问题讨论】:

  • 在重新构建之前,您是否尝试在您的 android 项目中运行“gradlew clean”?
  • 是的.. 多次

标签: android flutter


【解决方案1】:

确保您至少使用 Flutter 2.2.2。我有同样的问题,但我能够通过以下方式解决它:

  1. 更新我在pubspec.yaml 中的所有颤振插件
  2. 将颤振更新到 2.2.2
  3. 尽量避免在本机端使用插件(如果不需要)
  4. compileSdkVersion 30 和 targetSdkVersion 30
  5. ext.kotlin_version = '1.4.32'
  6. 类路径'com.android.tools.build:gradle:4.0.1'
  7. android.enableR8=true 在你的 android/gradle.properties 中

【讨论】:

    【解决方案2】:

    我找到了解决方案。就我而言,问题是由location: ^1.4.1 包引起的。我通过使用geolocator: ^5.1.1 的替代包解决了这个问题。我希望这对某人也有帮助,祝你好运。

    【讨论】:

      猜你喜欢
      • 2021-03-04
      • 1970-01-01
      • 2020-09-23
      • 2021-12-30
      • 1970-01-01
      • 1970-01-01
      • 2023-01-16
      • 2017-08-20
      • 2018-05-31
      相关资源
      最近更新 更多