未解析参考:嵌入和未解析参考:MainActivity.kt 中的 FlutterActivity

时间:2021-03-20 09:57:34

标签: android flutter

我的 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.

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

2 个答案:

答案 0 :(得分:0)

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

  1. 更新我在 pubspec.yaml 中的所有 flutter 插件
  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 中

答案 1 :(得分:0)

我找到了解决方案。就我而言,问题是由 "title": { "mapping": { "analyzer": "mmc_custom", "index": "analyzed", "store": "true", "term_vector": "with_positions_offsets", "type": "string" } } 包引起的。我通过使用 location: ^1.4.1 的替代包解决了这个问题。我希望这也能帮助别人,祝你好运。