ub0r logg0r is just a simple wrapper around the android.util.Log class.
It allows you to write things like Log.d(TAG, "foo=" + foo + ", bar=" + bar)
as Log.d(TAG, "foo=%s, bar=%s", foo, bar)
or Log.d(TAG, "foo=", bar, ", bar=", foo)
.
This simple change allows you to remove Log.d()
and Log.v()
with with proguard WITH the strings you are passing to it.
Just add the following lines to your proguard configuration:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
-assumenosideeffects class de.ub0r.android.logg0r.Log {
public static *** d(...);
public static *** v(...);
}
Either include it in your project as an android library project, or grab it via maven:
<dependency>
<groupId>de.ub0r.android.logg0r</groupId>
<artifactId>logg0r</artifactId>
<version>{latest.version}</version>
<type>jar</type>
</dependency>
Or add it in your build.gradle
repositories {
maven {
url 'https://raw.githubusercontent.com/felixb/mvn-repo/master/'
}
mavenCentral()
}
dependencies {
compile 'de.ub0r.android.logg0r:logg0r:+'
}
To migrate to this library you need to:
- Change the imports from android.util.Log to de.ub0r.android.logg0r.Log
- Use the new method parameters instead of concatenating strings in your app
A simple sed like this should do the work:
sed -e 's:android.util.Log:de.ub0r.android.logg0r.Log:g' -e '/Log.[dviwe](/s: *+:,:g' -i [your *.java files]
- Further reading, why this is necessary: http://stackoverflow.com/q/6009078/2331953
Copyright 2013 - 2014 Felix Bechstein
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.