Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 714
Muje Avatar asked Apr 11 '26 07:04

Muje


2 Answers

make sure you're on at least flutter 2.2.2. i had the same problem but i was able to fix it by:

  1. updating all my flutter plugins in pubspec.yaml
  2. updating flutter to 2.2.2
  3. try and avoid using plugins on the native sides (if not needed)
  4. compileSdkVersion 30 and targetSdkVersion 30
  5. ext.kotlin_version = '1.4.32'
  6. classpath 'com.android.tools.build:gradle:4.0.1'
  7. android.enableR8=true in your android/gradle.properties
like image 60
Pcechz Avatar answered Apr 12 '26 19:04

Pcechz


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.

like image 37
Muje Avatar answered Apr 12 '26 20:04

Muje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!