1
나는 안드로이드 스튜디오 2.2.2 gradle을 사용하고 있습니다. 이 방법으로 build.gradle에서 Proguard를 사용하고 있습니다. Proguard를 사용하여 로그인 인쇄를 방지하는 방법 릴리스 빌드에서 안드로이드
-keepattributes EnclosingMethod
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-dontwarn sun.misc.Unsafe
-dontwarn org.w3c.dom.bootstrap.DOMImplementatio Registry
-keep class * extends android.
-assumenosideeffects class android.util.Log { *; }
-assumenosideeffects class java.io.PrintStream {
public void println(...);
public void print(...);
}
지금 내 MainActivity.java에 내가 oncreate--
int i=0;
Log.d(TAG,"i val:"+i++);
Toast i value
그리고 출력 항상 "나는 발에 뭔가를 확인 여기
buildTypes {
release {
// Enable ProGuard
minifyEnabled true
shrinkResources true
// Common release options
zipAlignEnabled true
debuggable false
jniDebuggable false
// Notice that the default ProGuard file (SDK-provided) also enables optimization
// Here we also include a third file which disables the logging (see below)
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
// We enable ProGuard also for debug builds
minifyEnabled true
// Notice that the default ProGuard file (SDK-provided) differs from the release one
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
그리고 내 난독 화는 ... : 1". 이제 내 질문은 로그 라인이 실행되는 이유는 무엇입니까?
I을 이것을 사용하고 싶지 않으므로 Proguard를 사용하여이 작업을 수행합니다. – Subho
대체하십시오 -assumenosideeffects class android.util.Log {*; } to this -assumenosideeffects class android.util.Log { public static *** d (...); public static *** w (...); public static *** v (...); public static *** i (...); } –
이와 같은 작업을 수행하려는 경우 Jake Warthon의 Timber를 사용하는 것이 좋습니다. https://github.com/JakeWharton/timber 그것은 문자 그대로 하나의 클래스이며 이미 Crashlytics 또는 릴리스와 유사하게 로그인 할 수 있도록 허용합니다. –