Since update AS 1.1 Preview 2, I'm getting red lines under all my Log
messages
Log.d(TAG, "message");
With message: "The logging tag can be at most 23 characters..".
I didn't update anything fundamentally, except Android Studio itself. Is this a bug?
You can disable it if you so choose.
In Android Studio, Analyze->Inspect Code.
Under Inspection Profile, click on the button with the 3 horizontal dots.
The following window should open. Search for "log" and uncheck "Too Long Log Tags".
Update: Android Studio 2.2, it is located under Android Lint: Correctness
You can never ignore this lint check, it definitely could bring unexpected results on your release version since it throws exceptions and stops executing (it would not crash your app).
I have had a terrible lesson learned recently: it's OK on debug mode, but behave differently on release version.
No, it's not a bug.
From Android Studio's Recent Changes on 1.1 Preview 2,
As shortly explained on the recent changes, it's due to how
Log
API doesn't allow tag that exceeds 23 characters.SLF4J Android has an explanation to this:
which matches the Android's source code.
Currently, the only function that explicitly mentions this exception is
Log.isLoggable()
,However, based on the comments, apparently the logger does throw the exception on release mode (it's ignored in debug mode).
You can disable the lint checking by following Terence's answer, but you've been warned.
This is recent change and In this build, its a new lint check. Which says,
Checks that the tag passed to the logging calls, if its value can be resolved, is at most 23 characters long (as required by the Logging API.)
For more info, read 3rd point in below link.
https://sites.google.com/a/android.com/tools/recent/androidstudio11preview2
If you dont want to get this, minimize the number of characters in your TAG and make sure that they wont cross the length more than 23.
Complementing the answer by @Terence
You can also turn off the specific check via gradle with this in your build.gradle file:
Or by adding a lint.xml file to your project with xml: