androidflutter

Unresolved reference: embedding and Unresolved reference: FlutterActivity in MainActivity.kt


My flutter app was working fine until days I go when it stopped building successfully

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

package com.apps.myapp

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
 
}

Console

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.

Help in fixing this issue please! thank you.


Solution

  • I found solution on this. In my case the problems were being caused by location: ^1.4.1 package. I solved this issue by using an alternative package which is geolocator: ^5.1.1. I hope this helps someone too, good luck.