0

I have a Flutter project where, all of a sudden, without me doing anything special as far as I can remember..the Android side has started to show an error, and I am totally lost, I have no idea at all of what is wrong or why that happened.

That is what I see when I open the android folder, the MainActivity on the flutter project on android studio:

enter image description here

I have tried calling flutter clean, restart/invalidate cache, gradle clean...and so far nothing works.

The weird thing is that the project actually runs in the emulator without any problem. And also, if I open the Android part independently on Android Studio i don't see any error.

Anyone had that before?

Android Studio version 3.3.1

Solutions of this answer do not work.

** ----- NOTE ----- **

The problem here can be (not sure at all maybe someone else can help here) that I am using a flutter package called ImagePicker, which after some code investigation, it turns out that it is using some AndrodX imports....and...as far as I am aware of...Flutter is not yet compatible with AndroidX.

But i need someone else to confirm that in order to post a solution.

3
  • Did you try to run the application, Sometimes AS shows falsy errors! Commented Mar 28, 2019 at 9:12
  • @OmarHossamEldin what do you mean?, of course I ran it many times in emulator and it runs ok, it is mentioned in the question. Commented Mar 28, 2019 at 9:14
  • then this just a bug in AS, Sometimes can be solved by clean project, or invalidate cache Commented Mar 28, 2019 at 9:53

2 Answers 2

2

This error is not really an error. This happens because android studio is set to read and edit dart not java. In order to edit the android side of a flutter project, you need to click on the android folder -> go to the flutter option -> click 'open in Android Studio'.

This will then allow you to edit the android side of your project.

Sign up to request clarification or add additional context in comments.

2 Comments

hi, thanks, please see my question when i mention: And also, if I open the Android part independently on Android Studio i don't see any error....I am trying to get rid of the "error red mark" on the whole flutter project
The red error mark, would not reflect an error on the respective Android or iOS sides. This means there is an error somewhere else.
0

Set Configure to the Android project SDK of flutter application

Step by Step

  1. Click on File -> Project settings then select appropriate API level as per your project will solve your issue

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.