Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19821] Android 6.0: Device & emulator logs don't show up in studio console

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-11-24T20:10:45.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sRelease 5.2.0, Release 5.1.2
ComponentsAndroid
Labelslog
ReporterLokesh Choudhary
AssigneeChristopher Williams
Created2015-10-29T00:36:37.000+0000
Updated2016-04-27T02:19:55.000+0000

Description

*Checked with latest 5.0.3 & 5.0.2.GA & did not see any logs from android 6.0 in studio.*

Steps To Reproduce:

1. Use the code below in your app.js:
var win = Ti.UI.createWindow({ 
    title: "Test" 
}); 
var button = Titanium.UI.createButton({ 
   title: 'Hello', 
   top: 10 
}); 

button.addEventListener('click',function(e){ 
   Ti.API.info("This is info log"); 
   Ti.API.debug("This is debug log");
   Ti.API.error("This is error log");
   Ti.API.trace("This is trace log"); 
}); 
 
win.add(button); 
  
win.open(); 
2. Build for android 6.0 device/emulator. 3. After the app launches tap on the button & the window & check if you see logs in the studio console.

Actual Results:

1. No logs are seen on studio console from android 6.0 device/emulator. *Note: The logs appear fine on android logcat.*

Expected Results:

1. We should see logs from android 6.0 device/emulator on studio console.

Comments

  1. Chris Barber 2015-11-11

    Do you see the log output when you build the app from the CLI?
  2. Adam Paxton 2015-11-11

    [~cbarber] tested via CLI and do not see logs when building to a 6.0 device. Same build to a 4.4.4 device and I do see the logs. Both device's logs appear in logcat. {noformat} Name = Mac OS X Version = 10.10.5 Architecture = 64bit # CPUs = 4 Memory = 8589934592 Node.js Node.js Version = 0.10.40 npm Version = 2.14.3 Titanium CLI CLI Version = 5.0.5 Titanium SDK SDK Version = 5.1.0.v20151104190037 SDK Path = /Users/adam/Library/Application Support/Titanium/mobilesdk/osx/5.1.0.v20151104190037 Target Platform = android {noformat}
  3. Chris Barber 2015-11-11

    The log filtering is regex-based. It's possible that the log format has changed. I'll have to investigate.
  4. Ashraf Abu 2015-11-17

    Ran adb logcat on an Android 4.X vs an Android 6.0 On Android 4.X
       I/TiAPI   (25694):  This is info log
       D/TiAPI   (25694):  This is debug log
       E/TiAPI   (25694):  This is error log
       V/TiAPI   (25694):  This is trace log
       
    On Android 6.0
       11-17 00:28:55.383 13438 13471 I TiAPI   :  This is info log
       11-17 00:28:55.384 13438 13471 D TiAPI   :  This is debug log
       11-17 00:28:55.384 13438 13471 E TiAPI   :  This is error log
       11-17 00:28:55.384 13438 13471 V TiAPI   :  This is trace log
       
    [~cbarber] Yup. Your guess is correct. Log format changed in 6.0.
  5. Ashraf Abu 2015-11-17

    Android ticket mentioning Logcat changes in M aka Android 6.0 https://code.google.com/p/android/issues/detail?id=75694
  6. Ashraf Abu 2015-11-17

    Would running using adb logcat -B which is to output the log in Binary and then filtering that make it future proof?
  7. Chris Barber 2015-11-17

    [~msamah] We already use the -b flag. https://github.com/appcelerator/titanium_mobile/blob/master/node_modules/titanium-sdk/lib/adb.js#L683 I'll take a look at the regex and figure out a regex that works with both output.
  8. Ashraf Abu 2015-11-18

    Ok! On a side note, the -b and -B flag do different things. At least according to when I use -h (Assuming you want to use/try -B, the output will no longer be plain text.)
         -b <buffer>     Request alternate ring buffer, 'main', 'system', 'radio',
                         'events', 'crash' or 'all'. Multiple -b parameters are
                         allowed and results are interleaved. The default is
                         -b main -b system -b crash.
         -B              output the log in binary.
       
  9. Fokke Zandbergen 2015-11-18

    NodeJS module to read binary logical: https://github.com/openstf/adbkit-logcat
  10. Christopher Williams 2015-11-23

    Found the source of our woes: They changed the default format used from "brief" to "threadtime", so we're trying to parse a brief output format but getting another. We can probably just fix this by explicitly specifying we want the brief format in our command line args. https://android.googlesource.com/platform/system/core/+/649fc605f8094c06a38251466ccb15a722e8a91f%5E%21/ And just for completeness, here's how they spit out threadtime formatted logs: https://github.com/android/platform_system_core/blob/master/liblog/logprint.c#L1346 Looks to be: time, pid, threadid, loglevel, tag, message
  11. Anders Dahl Pape 2015-11-23

    @cwilliams Is it possible to make some changes locally to make it work untill a fix is released? I quite badly need to debug some errors on Android 6.0.
  12. Christopher Williams 2015-11-23

    [~andersdp] yes, basically open your SDK (say ~/Library/Application Support/Titanium/mobilesdk/osx/5.1.0.GA/), go into the node_modules/titanium-sdk/lib/adb.js file and apply the fix I did in this commit: https://github.com/sgtcoolguy/titanium_mobile/commit/949b636eaf7ae7c699c9395840f41184e849c9e4 line 683 becomes:
        var child = spawn(results.sdk.executables.adb, ['-s', deviceId, 'logcat', '-v', 'brief', '-b', 'main']); //, '-s', '*:d,*,TiAPI:V']);
        
  13. Anders Dahl Pape 2015-11-24

    @cwilliams It works. Thanks :)
  14. Lokesh Choudhary 2015-11-25

    Verified the fix. We see logs in studio from android 6.0 device & emulator. Closing. Environment: Appc Studio : 4.4.0.201511241829 Ti SDK : 5.2.0.v20151125112632 Ti CLI : 5.0.5 Alloy : 1.7.26 MAC Yosemite : 10.10.5 Appc NPM : 4.2.2 Appc CLI : 5.1.0 Node: v0.12.27 Nexus 6 - Android 6.0 Emulator - Android 6.0
  15. Chee Kiat Ng 2015-11-26

    To Note: This ticket is marked 5.1.2 but PR was merged in 5.1.1GA
  16. Be Rushton 2016-04-26

    I still don't see logs in CLI, was this fixed for CLI or just studio?
  17. Abdiel Aviles 2016-04-26

    Same thing still happens to me. I still rollback to using adb.
  18. Abdiel Aviles 2016-04-26

    And I use the Studio, so yes, still affects Studio.
  19. Ashraf Abu 2016-04-27

    [~bearus] and [~abdielou] Could you provide more information on when and how this is happening. Also how it can easily be reproduced. Eg, Device, Android version etc etc.
  20. Abdiel Aviles 2016-04-27

    LG G4, Android 6.0, OS X 10.11.4, latest Ti, Studio and SDK. It also used to happen on a Nexus 5 device with Android 6.0. But I don't have that device anymore.
  21. Abdiel Aviles 2016-04-27

    Oh, and about easily reproducing... I'm afraid that's the not so easy part.
  22. Ashraf Abu 2016-04-27

    So, it's something that doesn't happen often?
  23. Abdiel Aviles 2016-04-27

    It does happen often. It would log normally and after a code error it would stop logging. Other times it just stops logging after a LiveView reload. But what I meant is, that in order to give you a reproducible example, I would have to download one of your sample apps and start testing to see if it happens. And that will take me more time that I have now. So again, not so easily reproducible. I'm also afraid that this is particular to the app I'm maintaining. It is a poorly written app (a fairly complex app), which I did not wrote btw, and with many issues that I've been fixing along the way. And the reason, why I say that I'm afraid it might only happen to my app, is that this app also fails to stop at breakpoints. I was also asked on another ticket to give a reproducible example but the debugger runs fine on the sample apps and I can't simply share this damm code. So yet again, not so easily reproducible.
  24. Ashraf Abu 2016-04-27

    I now understand what you mean by not so easily reproducible. If you happen to be able to easily reproduce it, do update this ticket. [~bearus] Any additional information on your end?

JSON Source