gpt4 book ai didi

android - 在哪里添加 Proguard 自定义规则?

转载 作者:搜寻专家 更新时间:2023-11-01 08:28:07 27 4
gpt4 key购买 nike

我正在尝试为我的应用程序添加自定义 Proguard 规则,但我不确定应该将这些自定义规则添加到哪个文件中。我知道三个文件

1)Android/sdk/tools/proguard/proguard-android.txt
2)Android/sdk/tools/proguard/proguard-project.txt
3)Project --> app --> proguard-rules.pro

最佳答案

首先你会使用

3)Project --> app --> proguard-rules.pro

few generic custom rules which are safe to apply on app and wouldn't hinder the functioning of it

取决于您应用程序中的代码,但如果您将 minifyEnabled 设置为 true(推荐),这可能会导致很多问题,这些问题可以通过 proguard 规则文件解决。

这是我使用 Fabric、httpApacheClient、shareActionProvider 和其他一些需要混淆器特定规则的库的项目之一的混淆器文件。

 # This will ignore warnings for missing translations and some other wanrinings 
-ignorewarnings

# Keeping line numbers for easy error tracking :

-keepattributes SourceFile,LineNumberTable

# Support ShareActionProvider will not work without this line :
-keep class android.support.v7.widget.ShareActionProvider { *; }

# Flurry Crashlytics

-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int); }

# Preserve Flurry mediation classes for DFP/AdMob Ads ­keep public class com.google.ads.mediation.flurry.**

# Google Play Services library
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents(); }

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL; }
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *; }
-keepnames class * implements android.os.Parcelable { public static final ** CREATOR;
}

-keepattributes InnerClasses, EnclosingMethod
-keep class com.ironsource.mobilcore.**{ *; }
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn android.app.Notification

-keep class com.dianxinos.DXStatService.stat.TokenManager {
public static java.lang.String getToken(android.content.Context);
}

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

几乎你会在你使用的任何外部库的文档中找到相关的 proguard 设置。

关于android - 在哪里添加 Proguard 自定义规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42919876/

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