pdonlon
pdonlon

Reputation: 53

None of my logs are hitting

I have a bug in my Android application that I believe has to do with improper saving/loading of sharedPreferences. The bug is not easy to replicate so I'm not sure exactly what caused it originally.

I am now trying to debug my application with logs but none are hitting. I have put them as early in the code as I could think of in my MainActivity class.

In onCreate:

public void onCreate(Bundle savedInstanceState) {
    Log.e("LOG REACHED","onCreate");

In onStart:

protected void onStart() {
    Log.e("LOG REACHED", "onStart");

Is there any scenario where this would ever happen?

Upvotes: 1

Views: 66

Answers (2)

Narayan Acharya
Narayan Acharya

Reputation: 1499

Apart from what Mahmoud said, maybe your app isn't debuggable any more due to missing tags in the Manifest or build.gradle file. Try :

  1. Add android:debuggable="true" in the appicaltion tag in the AndroidManifest.xml file. or
  2. add debuggable true within the buildTypes like this

buildTypes{ debug{ debuggable true } }

All the best :)

Upvotes: 2

Mahmoud Abou-Eita
Mahmoud Abou-Eita

Reputation: 941

It's very likely that you cannot just read the log statements although they are being printed out, because of the inconsistent behaviour of logcat sometimes, especially if you're monitoring through Android Studio. I would try the following:

  1. Make sure I'm filtering out the correct log level, 'e' in your case.

  2. It's worth trying to unplug/replug the device or restart the emulator.

  3. Try to kill and start adb. adb kill-server then adb start-server

Upvotes: 3

Related Questions