I'm using Android Studio for Flutter App Development. Everything seems to be working fine just that the Android Studio does not show the "logs" in Logcat. In the Logcat section, it says "Please Configure Android SDK". Which is already configured. And in the Logcat section says "No Connected Devices." in the drop-down menu. When it has recognized my Android Phone and is showing it just under the Menu bar.
Is there a fix for it? Is there something I am missing?
Flutter use Run tab to display logs in Android Studio. Switch from Logcat to Run and then you will see logs.
Go to Setting/Preferences -> Languages & Framework -> Flutter -> Check or uncheck Replace the Run and Debug console with an experimental Flutter Loggin view
In Flutter apps you can log text using the print()
statement.
print('hello');
As others have said, you can use the Run tab in Android Studio to view these logged comments.
Here is the code for main.dart:
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Center(
child: RaisedButton(
child: Text('Button'),
onPressed: () {
print('hello'); // <-- logging
},
),
),
));
}
Switch to the “Run” tab to see the logs and if you want to insert logs (like Log.d()
in android), you can use print()
function and whatever string you pass into it will be printed into the “Run” window.
I guess it's an ADB issue. You can restart AS (or maybe even your Computer) or what i usually do is open the terminal an then: adb kill-server && adb start-server
(I think the second part adb start-server
is not necessary because it seems that AS handles it automatically) - anyways this is how LogCat and Android (and Flutter) work for me every time.
Flutter has not logcat flutter show error in the console inside Run tab.IF you want to see error and crash report click on run tab.
Just open another NATIVE project for Android Studio in other window and the logcat will work, do it while Flutter project is open. That was the solution for me
来源:https://stackoverflow.com/questions/51007784/android-studio-not-showing-logcat-with-flutter