在使用AndroidX时,proguard-android-optimize.txt中的“ @Keep支持注释”规则仍然适用吗?

问题描述 投票:0回答:1

通常将proguard-android-optimize.txt用作proguard文件。

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'

但是,当我浏览proguard-android-optimize.txt的内容时>

...

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

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**

# Understand the @Keep support annotation.
-keep class android.support.annotation.Keep

-keep @android.support.annotation.Keep class * {*;}

-keepclasseswithmembers class * {
    @android.support.annotation.Keep <methods>;
}

-keepclasseswithmembers class * {
    @android.support.annotation.Keep <fields>;
}

-keepclasseswithmembers class * {
    @android.support.annotation.Keep <init>(...);
}

我想知道,如果该规则仍然适用,我们是否使用AndroidX而不是支持库?我们是否应该在项目proguard-project.txt中明确添加以下规则?

# Understand the @Keep support annotation.
-keep class androidx.annotation.Keep

-keep @androidx.annotation.Keep class * {*;}

-keepclasseswithmembers class * {
    @androidx.annotation.Keep <methods>;
}

-keepclasseswithmembers class * {
    @androidx.annotation.Keep <fields>;
}

-keepclasseswithmembers class * {
    @androidx.annotation.Keep <init>(...);
}

通常将proguard-android-optimize.txt用作proguard文件。 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-project.txt'但是,当我经过...

android proguard androidx android-r8
1个回答
0
投票

我刚刚检查了一下,并用androidx.annotation.Keep注释类保留了它们。无需其他配置。

© www.soinside.com 2019 - 2024. All rights reserved.