Flutter Android Studio Troubleshooting: Could not Compile Flutter to Android device

This error also known as:

  • Device selection on Android Studio is greyed out.
  • Not applicable for the “main.dart” configuration.
  • Could not connect to lockdownd, error code -13.

What’s the symptom?

You will see this issue when you’re trying to compile to your Android device via Android Studio, but for some strange reason, you no longer see your mobile device to the left of “main.dart” dropdown.

Yep, no longer you see the leftmost dropdown.

You’ll instinctly When you move your mouse toward the third dropdown (or in your case, the second dropdown since the leftmost isn’t there), and see a popup saying “Not applicable for the “main.dart” configuration, and it isn’t clickable (of course).

You can attach any number of devices, but the leftmost dropdown will still not be there.

Because the problem is not in your device. There’s actually something wrong with your project’s SDK configuration, which prevent Android Studio from recognizing entry point, or recognizing what framework it is.

Now I don’t know whether this issue also appears on pure Android app using Java/Kotlin, but I only encounter this on Flutter on Android Studio.

How to solve this?

Open menu File > Project Structure.

First, choose the Project menu under Project Settings. You’ll see settings about Project SDK. It should says Android API level. But sometimes, once in a blue moon, it can says “<NO SDK>”.

The obvious thing to do here is to click on the Project SDK dropdown, and select whichever latest SDK listed there.

Next, choose the Modules menu under Project Settings. You’ll see your modules listed on the second column.

Select any module, and then look on the third column, where it has three tabs: Sources, Paths, Dependencies. Choose Dependencies.

Now, once again, once in a blue moon, the Module SDK can suddenly select “<NO SDK>”. Choose the same latest SDK you choose on the Project settings, which in my case, is Android API 29 Platform.

Repeat this for every module you have on the second column.

If you have done, click OK to close the screen.

Now, the Android Studio will adjusting itself to the new settings, and you’re (hopefully) will see the device selection to the left of the “main.dart” dropdown, which will indicate that you now able to compile to the device selected.

Hope it helps! If you have any other issue, leave it in comment below and see if I can help you. Thanks!

Source: https://flutterforum.co/t/emulator-field-grayed-out-not-applicable-for-the-main-dart-configuration/317/9