'Cannot resolve symbol FlutterActivity
I imported flutter project from github into Android Studio with 'VCS -> Checkout from Version Control'. And now I'm facing the issue: Cannot resolve symbol FlutterActivity
in android's MainActivity.java.
I created another flutter project with New Flutter Project
wizard. And there was no that kind of issue. The difference between the two projects was that the project from github didn't have External Libraries/Flutter for Android/flutter.jar
whereas created from scratch one had.
I compared pubspec.yaml and build.gradle files of both projects and didn't find anything that looks like related to that dependency.
Here the pubspec.yaml of the project in question:
name: utopian_rocks_mobile
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: ^0.12.0
rxdart: ^0.19.0
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
How that kind of dependency supposed to be handled in a flutter project?
Solution 1:[1]
When a project is created with flutter create foo several files in the ios/ and android/ sub-directories are created.
Newer Flutter versions might generate these files a bit differently and projects created with older Flutter versions might cause issues.
Ways to fix
Delete the ios/
and/or android/
directories and run flutter create .
to re-generate these directories.
Hint
Custom changes will be lost and need to be re-applied. This is easiest if the project is committed to a version control system like Git.
Solution 2:[2]
create a new flutter project using android studio you can not find the FlutterActivity class because of android studio can not find the flutter SDK path .
Solution 3:[3]
You could try linking android folder as a gradle project. Right click on the android/build.gradle file and select link as gradle project. Then you can refresh dependencies in the gradle tool window.
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 | Günter Zöchbauer |
Solution 2 | Rishita Joshi |
Solution 3 | chAmi |