Android studio does not show any Logs I wrote in my code. I have tried putting the log to verbose and debug. I am using 'No filters'. Why is 'Oncreatetestlog' not showing up in my logcat?
package com.example.keydown;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState != null) {
Log.d("Oncreatetestlog", "onCreate() Restoring previous state");
/* restore state */
} else {
Log.d("Oncreatetestlog2", "onCreate() No saved state available");
/* initialize app */
}
}
}
Go to File -> invalidate caches / Restart. And let Android Studio to index your project again. It works for me.
After hours of searching and trying, I found out it did not have to do with Android Studio, but that my phone didn't allow Logging. See this answer for more information.
Alternatively, you could use System.out.println()
to show the text in logcat
Replace
Log.d("Oncreatetestlog", "onCreate() Restoring previous state");
With
System.out.println("Oncreatetestlog onCreate() Restoring previous state");
If Log.d is not showing in your Logcat just replace Log.d
with Log.wtf
Like this:
Replace:
Log.d("tag",""+catstr);
With:
Log.wtf("tag",""+catstr);
It Works..happy coding;)
Please check in "Run" on the right side of "Debug" on the bottom of the IDE. in my case i actually did everything what they told but yet it's not working. so i checked there and i fount all the log over there. thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.