A couple of days ago, a question popped on StackOverflow, asking how to link a log line in LogCat to the source code, just like it happens when you Log an exception.
The first answers where to add a fake Exception. Naturally, there will be the line you want, but also a lot of noise in your LogCat.
Then someone proposed a method to simulated an exception Log, without the whole stacktrace (see the answer here).
The solution works fine, but can be quite verbose. With a little bit of try and error, I found out that the most important part is the "at (file.java:42)". It doesn't matter where it is in the message. You can even have mor than one, it only takes into account the last one.
So I worked out a LogLink class to use this systme anywhere and seamlessly. Here's an example of how it works :
// can be one of INSERT_FIRST, INSERT_LAST or INSERT_NONE
// default value is INSERT_LAST, and you can call it only once
// also exist as v, d, w, e and wtf
LogUtils.i("MyClass", "A message");
The previous code will output the following output
MyClass A message at (MyClass.java:42)
You can see and download the LogUtils class here
Axel v2.1 has been released today, and with it a few new things to enhance the user experience. It also went further with non XML files. As I said earlier, Axel can open compressed XML files from Android APK archives. It can now also open binary PList files (mainly used by Apple tools).
This was the occasion to update the sources on GitHub, and create two new independant libraries :
- the full source code for Axel in its version 2.1 is now up to date;
- this (Android) java library implements a parser for binary Android XML files;
- another Android library, meant to parse binary PList files;
And as always, if you have any trouble with one of my app or one of my repo on github, please let me know.
When one generates and Android Application, it's source code is compiled inside an APK (which stands for Android Package). XML resource files are also compressed in a binary file format, and the obtained file is no longer a valid XML document.
Many people assume that those file, with the .xml extension, could be opened with Axel, my XML editor / viewer for Android, which unfortunately was not possible.
I've just released a new version of Axel, which now allow you to view and edit such compressed XML files. This feature is still in beta, but it is working quite well for most compressed XML files. If you have any trouble with this feature, please let me know.