serkan stack serkan stack - 1 month ago 7
Android Question

Log.d is not working when filtering logcat

My verbose logcat is not working for

Log.d("b","Hi stack.");


because I am filtering logcat with gc.uploaderimager(my package name). If I don't filter the logcat with my package name logcat is being too fast, excessive messages.

1 week ago, there was no problem and I remember that I did not any filtering and no excessive messages. What did happen 1 week ago? I couldn't understand.

Now, I can not see log messages if do filtering.

My logcat is too fast and not readable if do not filtering.

Then what is the solution?

package gc.uploaderimager;
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);

Log.d("b","Hi stack.");
}
}


enter image description here

Answer

The Android Monitor view in Android Studio is a little flaky from my experience. Your app's package name should appear in the combo box where it currently says "No Debuggable Applications". You should restart adb by typing adb kill-server and then adb start-server from the command line. (You may need to cd to the platform-tools directory in your Android SDK installation or add this directory to PATH in your operating system configuration.) You might also need to restart Android Studio after doing this.

Since Android Studio has problems with viewing logcat, many developers use third-party tools instead. pidcat from Jake Wharton is one popular choice.

Addendum:

Part of the problem is that your log output doesn't include the package name in the line of output:

11-05 23:28:58.554 28331-28331/? D/b: Hi stack.

The ? should be your package name instead. In fact all of the lines in your output has this ? where a package name should be. I don't know the exact cause, but there are some things that I can think of checking:

  1. Be sure that USB Debugging is enabled on your phone.

  2. Restart adb as explained above. You can also try the Restart button in the left-hand toolbar in the Android Monitor window in Android Studio.