gpt4 book ai didi

java - 混淆不适用于proguard

转载 作者:行者123 更新时间:2023-11-29 04:34:13 24 4
gpt4 key购买 nike

我正在使用其他各种库。但是我已经从他们的存储库文档中添加了他们的 proguard 配置,我无法使用 proguard 混淆我的代码及其内部变量。即使我也无法混淆包名。我仍然可以在我的 android logcat 上看到日志。我的应用程序正在运行,没有任何崩溃。我很困惑是否应用了缩小。

这是我的应用级gradle

   defaultConfig {
resConfigs "en"
applicationId "com.xxx.xxx"
minSdkVersion 16
targetSdkVersion 25
versionCode 49
multiDexEnabled true
versionName "1.4.2-debug"
}
buildTypes {
debug {
minifyEnabled true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
dexOptions {
javaMaxHeapSize "4g"
}

这是我的 proguard 规则文件。

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
public static <fields>;
}
#################################################################### Fragmenst

-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment


#################################################################### Methods

-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers class * {
public void *ButtonClicked(android.view.View);
}



#################################################################### Serializables

-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[]serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}

#################################################################### KEEP ANDROID SUPPORT V7 AND DESIGN

-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }

-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}

-keep interface android.support.v4.** { *; }
-keep interface android.support.v7.** { *; }
-keep class android.support.** { *; }

#################################################################### REMOVE WARNINGS


-dontwarn android.support.design.internal.**
-dontwarn com.google.android.gms.**
-dontwarn android.support.v4.**


#################################################################### REMOVE LOGGING

-assumenosideeffects class android.util.Log {
public static *** e(...);
public static *** w(...);
public static *** wtf(...);
public static *** d(...);
public static *** v(...);
public static *** i(...);
}

最佳答案

我无法使用 proguard 混淆我的代码及其内部变量:

您的应用程序似乎没有混淆,因为您的 progaurd 规则过于宽泛,它们阻止了您的大部分代码被缩小和混淆。例如下面一行:

-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

我仍然可以在我的 android logcat 上看到日志:

您必须从 gradle 的 release buildType 中删除 debuggable true 以防止在 logcat 中看到日志。

关于java - 混淆不适用于proguard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42394082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com