【问题标题】:Dexguard does not encrypt classes and makes problems with manifestDexguard 不加密类并在清单中产生问题
【发布时间】:2018-11-20 08:38:43
【问题描述】:

我使用 DexGuard,在发布模式下构建项目:

proguardFile getDefaultDexGuardFile('dexguard-library-release-aggressive.pro')

一切都很好,但现在我需要阻止另一个类加密,我添加了几行不加密我的 ExampleBuilder:

-verbose

# do not encrypt API package
-keep public class com.justexample.api** {
public protected private *;
}

#these 3 lines below I added
-keep public class com.justexample.ExampleBuilder.** {
    public protected private static *;
}

-repackageclasses com.justexample

现在当我尝试使用库时出现错误:

error: attribute 'android:name' in <service> tag must be a valid Java class name.
Message{kind=ERROR, text=error: attribute 'android:name' in <service> tag must be a valid Java class name.

生成的清单(来自受 dexguard 影响的 AAR)是此错误的来源,错误所在的片段:

<service
        android:name="com.justexample.services.゚"
        android:exported="false" />

【问题讨论】:

    标签: android dexguard


    【解决方案1】:

    android:name 应该具有代表活动的类路径的引用。它不能包含任何特殊字符或空格。

    我相信你在 android:name 标签下的清单中你保留了一个额外的空格和句号 (.)

    尝试删除它并检查

    <service
            android:name="com.justexample.services"
            android:exported="false" /> 
    

    如果您的服务类有一个特定名称,请完整提及并检查如下

      <service
                android:name="com.justexample.services.SampleIntentService"
                android:exported="false" /> 
    

    更新:来自您的 cmets,

    从 Dexgaurd 中删除此行并检查

    -repackageclasses com.justexample
    

    【讨论】:

    • 但不幸的是,这个 Manifest 来自我开发和使用 Dexguard 的 Android 库 (AAR)。我用 dexguard 构建了我的 AAR,后来我在我的 android 测试应用程序中使用了这个 AAR,我得到了来自 AAR 的 Manifest 无效的错误。在源代码 AAR 中,我的清单是正确的。 Dexguard 加密类并更改 AAR 清单。但这很奇怪,因为一切都很好,直到我添加了几行以防止另一类加密 - 生成器。当没有行来阻止 Builder 加密时,生成的清单是好的并且没有错误。
    • 在测试应用程序中我不使用 Dexguard。第二 - 如果您使用 dexguard-project 配置查看我的第二部分,当我从该配置中删除 3 行(在此处注释下)时,我可以在测试应用程序中正确使用我的 dexguarded AAR。只有当我尝试从加密中排除一个类时,结果是,我打开测试应用程序项目并收到来自 AAR 的清单不正确的错误。在我看来,这并不相关,这很奇怪。当我不从加密中排除一个类时,不会出现android:name in service不正确的错误。
    • 删除这一行并检查 -repackageclasses com.justexample
    猜你喜欢
    • 2017-09-25
    • 2012-10-26
    • 2014-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多