Android Studio not showing Logcat with Flutter - android

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?

Try the following:
Event Log (a tab at the bottom right)
scroll to Android framework is detected
click Configure
The Logcat tab should appear now. Moreover, the Device File Explorer tab should show up on the right panel.

I just solved this, the flutter project was missing an Android module. Go to 'File -> Project Structure -> Modules'. Click on the '+' sign at the top to add a module. Select Android.

Update April 2020: Cuong's answer works better with Android Studio 3.6+
Previous answer:
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

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

Find a way around it (macOS).
Go to Project Structure -> Facets -> "+" -> Android -> Select Project.
Logcat should now be visible. Configure Android SDK if not done previously and you should be able to use Logcat.
Reference https://github.com/flutter/flutter-intellij/issues/2724

When I first came to Flutter from an Android background, I didn't know where to find the log statements. I didn't care so much about all of the system messages. I just wanted to see log messages from my app during development. This answer is for people like that, not for people who specifically need LogCat itself.
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
},
),
),
));
}

Open Project Stucture -> Modules -> new android module from exists source.
Logcat & Device File Explorer will be visible.
for Android Studio 3.6:
File -> New -> New Module -> Android Library

I had this issue:
I have done the following steps to resolved it:
Click the event log on the bottom right of android studio
Click on configure
Click on Ok in the dialog box
Logcat will be available now

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.

1.Go to Menu and select 'Project Structure' -> 'Project'
2.In 'Project Structure' Select Project SDK
And just now click on OK and Apply.

Just use command 'flutter logs', then you can see all logs which are printed by 'print' or 'debugPrint' function.

When i face this problem I just go to File and open my existing native android project and then close it. This solution also works when abd Wifi pludings does show warning like => adb not found.

Run
adb logcat
and watch from terminal.
Doc: https://developer.android.com/studio/command-line/logcat

when you open flutter project, IDE prompts you to configure android project. Just click on the recommendation and it will start showing logcat window.

In case you accidentally refused to configure Android framework and now struggling to find the LogCat window. Then delete .idea, .dart_tool and .gradle folders in project root and android folder. Then Invalidate and restart. It will ask to configure detected Android framework. Click 'configure'.

In new versions of Android Studio, after deploying the app to device/emulator, in Run Tab you will see an option for flutter dev tools as shown in the image, it will open in browser (based on default chrome/edge) and there you can see logcat/logging
Flutter Dev Tools

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 found a solution worked for me:
for MacOS:
Go to: /Users/userName/Library/Preferences/AndroidStudio3.4/options
Find "runner.layout.xml"
Change the name of this file for ex: runner01.layout.xml
Restart Android studio
for Windows:
1- Focus "Run" tab (click on tab header, not on its body)
2- Ctrl+Shift+A, find and click "Restore Layout"
References:
https://github.com/flutter/flutter/issues/25835
https://github.com/flutter/flutter-intellij/issues/3673#issuecomment-517356243
Hopefully, it helps.

In my case, I also had an error in the Device File Explorer: Error initializing ADB: Android Debug Bridge no found.
I fixed the problem following Error initializing ADB: Debug Bridge not found: I selected the latest Android API Platform as Project SDK in File/Project Structure.

close project
delete .dart_tool,.idea,build files
start android studio,logcat will display

Just go to File => Project Structure => and in the “SDK project” choose “Android”

Go to File > Project Structure Project or use cmd + ; or
Then click on "Facets" and press + icon in the upper right corner and add Android from the list.
Credit to #MrWeeMan

Some times for some reasons like flutter clean or changing in files directory, android studio usually excludes some files from project modules. here is some simple steps to help you solve the problem:
go to File --> Project Structure --> Modules
There are 2 common scenarios.
Android studio might have completely removed your project from modules. For this you need to add it again using steps shown in the picture below.
Click on the plus icon and the add your project here. Then press Apply and lastly OK.
Android studio just excluded some of the files and folders from your flutter project. In the right panel you can see them in red. just remove them from exclude list and again Apply and OK.
NOTE: In both scenarios you need to stop the project and rerun it. or better close and reopen android studio

You can enable verbose logging for flutter if you are looking for AppId or something of that sort.

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.

Related

Add Android Run/Debug configuration for Flutter project

I am working with a Flutter example project where it shows how to share a FlutterView inside an Android application (and iOS also).
While working with it I tried this:
I make changes to the android project like changing the theme color, if I do hot-reload/run for main.dart I don't see the changes reflected in the running app. I have to stop it from Android Studio and run the main.dart again to see the changes.
To solve the issue I was thinking to add a run/debug configuration for Android app module. So that I could run android app and not main.dart.
Is there a way how to achieve this in Android Studio?
One solution for me was to open the android(/flutter_view/android/app) project from a new window in Android studio. I could run the app this way.
(But here I encountered another issue in case anyone has the solution).
According to my understanding you face problems when you open your project and try to run.
Android studio asks you to configure your project to be able to run...
It's easy to solve near to run button you will find "add configuration" button just press then from left side select "flutter" and put in the field "entrypoint" your main Dart file path main.dart...
EX. E:/project/lib/main.dart....
Then from top right corner press "create configuration"...
That's it.
For Configure your Flutter app on Android you have to Upgrade Gradle file..
So Go to the Tool and at you will find AGP upgrade Assistant..
It Download new Gradle file then its Config automatic..

When I try to run my app back in Android Studio an “Edit Configuration”

I have a project files.i need to understand the flow of the project but When I try to run my app back in Android Studio an “Edit Configuration” tab appears and I have the options to update settings regarding the package, activity and target device however I am not sure what to select.
Has anyone else come across this problem? please help me
OK. I got you .
Please follow the steps below:
Click on File -> Project Structure ->(under Modules click on) app -> [Now you can select 'compile sdk version' and 'build tools version' accordingly from this window] -> click OK -> sync your project -> now clean and run the project.
NB: You have to choose the sdk version and build tools version - which is already downloaded in your android studio
It looks like you have not configured Android app, just click on the "Select Run/debug Configuration" which is on the left of RUN button and click on Edit Configurations. This will open a new screen where you can add a new configuration.
Another issue is, you might not have Sync the project.To sync the project, go to build.gradle file -> Sync Now. If it is not not working, then change accordingly and then press "Sync Now" or "Try again".
Also make sure that, if in case you have imported the modules, configure and import it correctly.And make sure that your build.gradle file is correct.
Re-opening the android studio worked for me once i got this issue.
In activity, select the Default Activity and in target device, Select whatever you are using(i.e Emulator or USB device).
Simply Solve the problem just in one click i.e
In Android Studio right side vertical "Gradel" option is there and click on "Refresh all Gradle Projects" (icon like refresh)
Updating the libraries worked for me.
Go to the event log on bottom right and it will show the libraries which are outdated or not working properly !

Run Button is Disabled in Android Studio

I can't click the run button. Does anyone know how to fix it?
Click Run on the menu and then Edit Configurations... then click on Android Application on the left and click the + button. Choose Android Application from the pop-up menu. Then pick the module (its normally app or something like that). Then click apply and ok.
If you have more errors after that, try to re-import the project in Android Studio.
When creating the Run Configuration, the dropdown for Module had only <no module> for me. Invoking menu File -> Sync Project with Gradle Files added app to the dropdown for Module. Then the Run button became enabled.
The above answer didn't work for me, instead closing the project and restaring the AS IDE worked for me.
Just click the dropdown button on left side of RUN button (in your image the dropdown which is in red box) select 'app' option from that and RUN button will be enabled.
Please refer below screenshot.
just to go File -> Sync Project with Gradle files then it solves problem.
for flutter project, if the run button is disabled then you have to
tools>> flutter>> flutter packages get >>enter your flutter sdk path >>finish
This should solve your problem...
Above answer didn't work for me, just do click File -> Invalidate/cache -> Invalidate and Restart.
open your existing application by selecting build.gradle file. it will automatically sync the project and run button will be clickable
Run 'app' button disable issue coming sometimes in Android Studio Dolphin
Sync your project with gradle files
It was quite silly for me, I just opened the Run > Run Configurations window
everything seemed to be fine there, I didn't change anything, when I closed the window the button was enabled.
If you have changed jdk version then go to File->Project Structure->Select SDK Location from left bar->update JDK Location in editbar in right bar.
If your IDE is in power save mode, then the run button etc. are also disabled.
You can verify this via the file -> power save mode, make sure it is disabled.
If you are on a Mac, try clicking on File, then click on "Sync project with Gradle files" .... Run button should turn green again in a few seconds.
if you're importing an eclipse project to android studio, you'll also encounter the same issue as above. Double Check if grade>app has
apply plugin: 'com.android.application' on the top as sometimes android studio imports it as a library.
You have to reconfigure the FlutterSDK path in Android Studio: Go to Setting -> Language & Frameworks -> Flutter and set the path to Flutter SDK
I just clicked on the debug icon and it started working.
Build->Clean Project
make the run button enable again in my case
For me increasing the version of compile SDK to latest solved my issue, Go to
build.gradle(app-level)
compileSdkVersion 30
Because My Emulator is Api-level 30
Select the project view in the android studio.
Remove all gradle folders.
Restart the android studio.
This will work.
The issue is happening since the gradle was configured for an android studio in another machine and the files pushed on the git and are using in your studio.
After removing these gradle files and restarting the studio, the studio will generate gradle files for your system. This will solve the issue.
I opened the wrong folder.... Verify is your root folder in Android studio has the build.gradle file.
If you are trying to run the Flutter Project in Android Studio, and the run button is disabled then here is the solution
Click on add configuration
and select Flutter and then select the main class in dataentrypoint
I'm using Linux where I had a symlink in my home folder pointing to a folder containing the Android Studio projects. Loading a project using the symlink failed, loading a project from the folder where the symlink is pointing to worked!
My solution was to go to that multiselect button, then "Edit Configurations" -> Go to "+" and select the module (in this case it would be an app if you do not have a multiproject -> then apply and OK
Happened to me twice, and then I figured out it happened after I upgraded my flutter version. When I opened (flutter SDK path) in (flutter) tab in (system preferences) I found it empty.
Solution was to point out to flutter directory on my disk from (flutter SDK path) in (flutter) tab in (Android studio preferences).
Run button is bounded with Configuration that is why you should check if your project is build, synced and indexed and after that you can select a Configuration
For me, more than 1 instance of adb was initialized and due to this run button was disabled. I had to open ActivityManager (on mac) and kill all the initialized adb instances.
go to Build-> Clean Project
Selecting a different build variant (in the Build Variants view), then reselecting the initial build variant, fixed this issue for me.

Restore LogCat window within Android Studio

I have recently started to use Android Studio v0.1.1, And i can't seem to find LogCat... Is it gone? Or if not, how can I enable it?
If it is gone, is there any way to enable something similar to log my app behavior (and mainly crashes)?
I think I still can find logcat in my installation of 0.1.1
Try pressing Alt+6 on Windows or CMD+6 on Mac.
Check if you have hidden it... Use Alt+6 to bring up the window and click on the button shown below 'Restore logcat view'
In Android Studio 3.4, In the case in which Logcat does not appear in View->ToolWindows->Logcat (in that case Alt+6 or CMD+6 will also not work), the way to get the logact window is:
File->Profile or debug APK (choose an APK)
Select new window or use current window.
Logcat is now available through the menu
(View->ToolWindows->Logcat) or through Alt+6 or
CMD+6
This issue is an indication that something is not configured correctly with the Android Studio project.
The above solution can be useful:
As a temporary solution when there are configuration issues with the Android Studio project, that for some reason are causing Android Studio to hide the logcat window.
When trying to use the Android Studio logcat window for debugging an app without an Android Studio project.
You can show it pressing Alt+6
Or...
Tools-> Android -> Android Device Monitor
will open a separate window
In my case, Logcat is showing in Android Project but not in Flutter Project.
In Flutter project, click on “Event Log” tab
it will show
23/03/20
6:52 Frameworks Detected
Android framework is detected.
click “Configure”, and it will show logcat
Android Studio 4.0.1
in my case when I press Alt + 6 it shows logcat with no problem but when I click to dismiss it will disappear again and will not be pinned at the bottom so I pressed this little button on the bottom left of the screen then it worked. hope it will help somebody :)
View -> Tool Windows -> Logcat (command + 6)
Open a separate terminal and start adb with logcat.
On my (linux) system;
~/android-studio/sdk/platform-tools/adb logcat
While I would be a little late for the party, it has been a few years and new version of Studio.
Today when you encounter the bug, your logcat would not be shown, to resolve this you would need to follow these steps:
Menu -> Build -> Make Project
in your settings.gradle comment out everything and sync.
uncomment everything and sync again.
Menu -> Build -> Make Project
Once the project build is done.. your Studio would be ready.
I have encountered several different bugs related to this issue, this scenario covers most of these cases.
In my case the window was also missing and "View -> ToolWindows -> Logcat (Alt + 6)" did not even exist. Pressing ALT+6 also had absolutely no effect whatsoever.
I fixed it this way:
connect a device
start ADB via Terminal ("> adb usb")
stop it again (ctrl + c)
close the Terminal window in the bottom left window next to the Event Log (via the red X)
After closing the terminal the Logcat window appeared in the tab list and the menu entry appeared in the "View -> ToolWindows" category.
In Android Studio 2.3.2 you will have to click on "Android Monitor" panel at the bottom and "logcat" is a tab of this pannel. See attachment.
If you do not have this panel you will have to go to Your main menu and then View->ToolBar/ToolButtons/Statusbar/Navigationbar
Choose "floating mode" then "Docker mode". It's worked for me!
When you are opening the project in the android studio instead of opening android directory open app directory
In AndroidStudio menus click: View\Tool Windows\Android
way one :
you can use bin icon in logcat
way two:
you can clear logcat after per lunch
Edit Configuration > Miscellaneous
check Clear log before lunch
Apparantly, when logcat is opened and Android Studio is switched to fullscreen mode and back, the logcat window is nowwhere to be found.
Solution:
Restart Android Studio.
Search Android Monitor tab bottom of android studio screen. Click on it. It will display a window and there is a tab call logcat.
If you can't see Android monitor tab, click Alt+G.
for me the device selection bar (or whatever it's actually called) in logcat tab doesn't show, to resolve this I had to move logcat to some other position (left/right) and move it back
If all of the above methods does not work then try the below mechanism. Sometimes, the android studio does not show logcat options because of the project you select is not an android project. If you want to debug an APK, create an empty android project then it will start showing the logcat option.
IN android studio 3.5.1 View -> Tool Windows ->Logcat
From 2022 to forth:
On top menu:
View -> Tool Windows -> Logcat
To show the bottom bar:
View -> Appearance -> Tool Windows Bar
Try going to Tools->Android->Enable ADB Integration
In my case it got automagically disabled
In my case, I see the window, but no messages in it.
Only restart (studio version 1.5.1) brought the messages back.
File ——> Project Settings ——> Facets + Andorid then apply
OK!
I hope you have installed the required drivers for debugging android programs on your machine. If that is the case, when you run an application from android studio in an actual device, it will pop up a message asking to enable logcat. If you have disabled that option, then you can enable the logcat view from Window menu -> Show view -> Logcat. Next time when you run your application on actual device or in an emulator, you can see the logcat is active.
If you are not able to view it with the above solution, you can view the logcat from command line by typing
adb logcat
You can view more information from here http://developer.android.com/tools/help/logcat.html

"Selection cannot be launched and there are no recent launches” when Eclipse for Android Project Dev

I am trying to open an unzipped Android Project using Eclipse but every time I try to run or debug it show this error: "selection cannot be launched and there are no recent launches".
So I looked it up and tried creating a new project from an existing source but opens with errors and I open the src etc folders. I also tried importing the project which didn't work either. There are no run as options and changing the run configuration didn't really help. I couldn't find any option to open it as an Android project.
Could you please help me to run this project.
(Since I unzipped this project there is a _MACOSX folder when I import and I am not sure if that matters or should I remove that folder.)
I am running Eclipse Juno SR 2
I had a similar problem. To fix the issue go to Run-> Run Configurations...
If there isn't create a new run configuration (top left)
Under Android tab: browse and select the project you want to run
Under Target tab: select Always prompt to pick device (or) you can pick automatic launch.
Similar solution can be applied to the Debug by going to Run-> Debug Configurations...
Update:
I realize this is beyond the scope of the question but if any new developers are coming to answer then I would suggest switching to Android Studio from Eclipse. AS is the official Google supported IDE for Android development and much nicer to use.
In the Package Explorer (the left column), right-click on the name of the project (the top item). In the menu that appears, select "Run as"; then choose "Android Application".
I fixed it for Version: Luna SR2 (4.4.2)
select run configurations from right side dropdown of run button.
double click on android application.
get changing window, select your project name by browsing button of "android" tap(there are 3 tabs).
from "target" tab select ADT or your device, in which you want to run.
then press "run" at right -bottom button, left-side of "cancel".
after few moment, you will get new windows. from there you can select your connected device or ADT.
If this file is and .apk, you should install it on emulator using following command:
adb install /path/myfile.apk
For more informations, you can chek following link: http://developer.android.com/guide/developing/tools/adb.html#move
Generally this error comes in eclipse IDE when you don't have a main() function in your code.
Check whether your program has public static void main(String [] args) in it or not.
I'm using a mac and this answer is for Kotlin inside Eclipse
I installed Kotlin from Eclipse MarketPlace, clicked the perspective tab , opened Kotlin, created a new Kotlin project named FirstProject and then clicked src and created a Kotlin file named FirstFile (it had the .kt extension) and typed in
func main(args : Array<String>) {
println("Helooooooo")
}
I pressed the green Run button but kept getting this screen.
To fix it, follow these steps:
Right next to that green run button is a drop down arrow, press it then choose Run Configurations
On the left side of the accompanying screen click Kotlin Script Launch Configuration and in the drop down click New_configuration then select Run
After the screen disappeared when I pressed the Run button again I got the same exact "This selection cannot be launched ..." screen. I deleted the project FirstProject and created another one SecondProject > src > Kotlin file > named it SecondFile, typed in the println("Heloooooooo") code and a screen popped up
I choose OK and the project ran fine.
For steps 1 & 2 I also did the same thing and choose Gradle (you can see it the picture) but I don't think that made any difference.

Categories

Resources