[TIMOB-19821] Android 6.0: Device & emulator logs don't show up in studio console
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-11-24T20:10:45.000+0000 |
Affected Version/s | Release 5.1.0 |
Fix Version/s | Release 5.2.0, Release 5.1.2 |
Components | Android |
Labels | log |
Reporter | Lokesh Choudhary |
Assignee | Christopher Williams |
Created | 2015-10-29T00:36:37.000+0000 |
Updated | 2016-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.
Do you see the log output when you build the app from the CLI?
[~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}
The log filtering is regex-based. It's possible that the log format has changed. I'll have to investigate.
Ran
adb logcat
on an Android 4.X vs an Android 6.0 On Android 4.XOn Android 6.0
[~cbarber] Yup. Your guess is correct. Log format changed in 6.0.
Android ticket mentioning Logcat changes in M aka Android 6.0 https://code.google.com/p/android/issues/detail?id=75694
Would running using
adb logcat -B
which is to output the log in Binary and then filtering that make it future proof?[~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.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.)NodeJS module to read binary logical: https://github.com/openstf/adbkit-logcat
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
@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.
[~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:
@cwilliams It works. Thanks :)
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
To Note: This ticket is marked 5.1.2 but PR was merged in 5.1.1GA
I still don't see logs in CLI, was this fixed for CLI or just studio?
Same thing still happens to me. I still rollback to using
adb
.And I use the Studio, so yes, still affects Studio.
[~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.
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.
Oh, and about easily reproducing... I'm afraid that's the not so easy part.
So, it's something that doesn't happen often?
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.
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?