可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
Flutter use Run tab to display logs in Android Studio. Switch from Logcat to Run and then you will see logs.
回答2:
Go to Setting/Preferences -> Languages & Framework -> Flutter -> Check or uncheck Replace the Run and Debug console with an experimental Flutter Loggin view
回答3:
In Flutter apps you can log text using the print()
statement.
pring('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 }, ), ), )); }
回答4:
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.
回答5:
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.
回答6:
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.