'Flutter Cannot resolve symbol 'embedding' and Cannot resolve symbol 'FlutterActivity'
error shown in Flutter Android project folder in mainactivity
package com.malik.database_demo;
import io.flutter.embedding.android.FlutterActivity;
public class MainActivity extends FlutterActivity {
}
Solution 1:[1]
Currently you are probably trying to directly edit the MainActivity class from your Flutter project. (By expanding android -> Navigation to 'MainActivity.java' or 'MainActivity.kt' and editing it).
I have observed that when we try to edit the native side code this way, Flutter is not able to recognize the android part.
What you can do is open the 'android' part of your flutter project and then edit it.
To achieve this :
- Click File -> Open -> Navigate to your current Flutter project -> Expand it and find the android part (refer the example below)
[1 = Your current Flutter project,2 = The android part of your flutter project]
- Click on that android part and click Open. Wait for the indexing and all to complete and then I dont think it will give those errors.
GLHF :)
Solution 2:[2]
I added flutter.jar as a library. This seemed to work.
I'm not sure if there are some unintended consequences yet!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sarvesh Dalvi |
| Solution 2 | dbarton_uk |

