简体   繁体   中英

LogCat doesn't show my own logs in real device

I have little test app in Android Studio with strange behavior regarding LogCat: For example I have logs like this:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate(Bundle) called");
        ...

If I try to start my app in emulator, all my logs work fine. But if I try to start my app on a real device, I can see a lot of system logs from my device(for example from BatteryService), but there are none of my own logs here.

I have enabled ADB integration and source of logs in LogCat choosed right(my device).

Assuming you already have USB debugging activated(othervise it will not work).
Open logcat and press the launch button. and as it goes to your device it should work normally. Now, if you are using the APK from google drive, the app store or anywhere else it will not work as debug access isn't there.

If you have done the above, you can try this method:

As you can see, there is a search box next to the 'Log level' dropdown menu. Search for your app(in format of a package name) and it will show up. From there, you can select a log level(if you feel like it). If you do not chose a log level and set it to verbose, all logs will show up, all types of log level.

And if that does not work, we can definitivly conclude with the fact that it is NOT USB debugging related. Then it might be because of configurations in build.gradle files, the Android Manifest, or maybe in the code. Also, in my experience, Proguard prevents log output, but you get output just not from your app. So if none of the above worked, check:

  • Android min version(by what your app can handle)
  • Android target version(in comparison with the newest current API which is right now 24)
  • (the same in build.gradle on app level)
  • Proguard on/off

And finally, if none of that works, download ACRA and convert the logs using the simplest backend(10 lines) and you have the logs on your website upon crash in .txt format. It is a hard workaround but at least you will be able to read any crashes.

Check for the dropdown in LogCat and change the option to Debug or D.
Being you have put your logs in Log.d("TAG","MSG");

Options are

  1. Verbose
  2. debug . Your logs will appear in this case
  3. info
  4. warn
  5. error
  6. assert

I found problem. Strange behavior of LogCat was because of API version of my device Android was lower than required API version of my app.

try this on your andorid device!

Performance Optimization - Advanced Log Output

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM