一个Android库项目,环境:

apply plugin: 'com.android.library'
classpath 'com.android.tools.build:gradle:3.2.1'
Gradle 4.9

AndroidManifest.xml
        <activity
        android:name="${applicationId}.PayloadActivity" />

当我使用ProGuard混淆代码时:
Caused by: proguard.ParseException: Expecting class member name before '}' in line 2 of file 'Y:\project\build\intermediates\proguard-rules\release\aapt_rules.txt'
    at proguard.ConfigurationParser.checkJavaIdentifier(ConfigurationParser.java:1486)
    at proguard.ConfigurationParser.checkJavaIdentifier(ConfigurationParser.java:1472)
    at proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:1049)
    at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:876)
    at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:659)
    at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:588)
    at proguard.ConfigurationParser.parse(ConfigurationParser.java:165)
    at com.android.build.gradle.internal.transforms.BaseProguardAction.applyConfigurationFile(BaseProguardAction.java:145)
    at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:254)
    ... 5 more

build \ intermediates \ proguard-rules \ release \ aapt_rules.txt:
# Generated by the gradle plugin
-keep class ${applicationId}.PayloadActivity { <init>(...); }

混淆失败是因为在编译为AAR时没有占位符分配。尽管困惑可以延迟到编译成APK之前。但是,由于内容的这一部分,我不希望被如此简单的反编译操作的APK用户看到。编译AAR时可能会感到困惑吗?

最佳答案

只需删除

<activity android:name="${applicationId}.PayloadActivity" />

从您的manifest.xml文件中。

关于android - 当ProGuard混淆AAR时,它会占位,导致失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53491696/

10-08 22:29