未解析的引用:嵌入和未解析的引用:MainActivity.kt 中的 FlutterActivity
Posted
技术标签:
【中文标题】未解析的引用:嵌入和未解析的引用:MainActivity.kt 中的 FlutterActivity【英文标题】:Unresolved reference: embedding and Unresolved reference: FlutterActivity in MainActivity.kt 【发布时间】: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”? 是的.. 多次 【参考方案1】:确保您至少使用 Flutter 2.2.2。我有同样的问题,但我能够通过以下方式解决它:
-
更新我在
pubspec.yaml
中的所有颤振插件
将颤振更新到 2.2.2
尽量避免在本机端使用插件(如果不需要)
compileSdkVersion 30 和 targetSdkVersion 30
ext.kotlin_version = '1.4.32'
类路径'com.android.tools.build:gradle:4.0.1'
android.enableR8=true 在你的 android/gradle.properties 中
【讨论】:
【参考方案2】:我找到了解决方案。就我而言,问题是由location: ^1.4.1
包引起的。我通过使用geolocator: ^5.1.1
的替代包解决了这个问题。我希望这对某人也有帮助,祝你好运。
【讨论】:
以上是关于未解析的引用:嵌入和未解析的引用:MainActivity.kt 中的 FlutterActivity的主要内容,如果未能解决你的问题,请参考以下文章
添加对WixUIExtension的引用会导致“未解析的符号引用...”
为啥它显示像 ld 返回 1 退出状态和未定义的引用 `powr(int, int)' 之类的错误