Proguard的忽略库的配置文件 [英] Proguard ignores config file of library

查看:598
本文介绍了Proguard的忽略库的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm面临的一个真正weired问题几天了...

I´m facing a really weired problem for days now...

我有一个摇篮应用程序有两个模块,一个主模块和一个库模块。

I have an Gradle app with two modules, one main module and one library module.

  • 在这两个模块我宣布这是正确的一个proguard-rules.pro文件路径
  • 在这两个.gradle文件,我已经minifyEnabled真正

下面是第一个问题:即使minifiedEnabled是虚假的图书馆,它就会被模糊处理。它完全没有影响,似乎取决于主module's设置。使用I'm ProGuard的,因为有一段时间了和我从来没有经历过这样的行为都没有。

here is the first problem: even if minifiedEnabled is false in the library, it gets obfuscated. it has no effect at all and seems to depend on the main module´s settings. I´m using proguard since a while now and I´ve never experienced such a behavior at all.

此外,库的proguard-rules.pro似乎被完全忽略。它doesn't不管是什么,我宣布在那里,所以不能用,结果始终是相同的(总是反编译,以查看结果)。 It's混淆使用默认设置。

Also, the proguard-rules.pro of the library seems to be completely ignored. It doesn´t matter what I declare there, it is not used and the result is always the same (always decompiled to view result). It´s obfuscated with the default settings.

从来就使用了无效ProGuard的文件名称,以查看该文件是否也摸不着,确实也有与错误的名称错误,它也complaines关于ProGuard的文件语法错误...

I´ve used an invalid proguard file name to see if the file is even touched, and indeed there are errors with the wrong name and it also complaines about syntax errors in the proguard file...

我不知道这是否是某种关系到Android Studio的更新,因为它也推荐我用minifyEnabled,而不是runProguard。

I don´t know if it is somehow related to an update of Android Studio, as it has also recommended me to use "minifyEnabled" instead of "runProguard".

我如何管理ProGuard的使用图书馆的proguard-rules.pro过?请帮我

How can I manage proguard to use the proguard-rules.pro of the library too?? Please help me

编辑:

从来就做出了示例项目clearify我的问题

I´ve made an sample project to clearify my problem

我的图书馆ProGuard的配置

The proguard config of my library

我的媒体库的摇篮:

最后在结果我总是得到。它doesn't不管我怎么排除/包括ProGuard的配置

And finally the result I always get. It doesn´t matter what I exclude/include in the proguard config

正如你所看到的,ProGuard的规则工作得非常好主模块上。它做什么,它应该。但它总是完全混淆了我的库AA ...

As you can see, the proguard rules work quite well on the main module. it does what it should. But it always fully obfuscates my library to a.a....

也已经完全删除了图书馆的活动,这shouldn't发生在所有的

It also has completely deleted the Activity of the Library, which shouldn´t happen at all

推荐答案

您通常不应启用ProGuard的库中的项目。 ProGuard的处理的应用程序和该库一起在应用项目,这是最有效的方法。

You typically should not enable ProGuard in the library project. ProGuard processes the application and the library together in the application project, which is the most effective approach.

在库项目中,可以在build.gradle指定任何库特定ProGuard的配置,例如:

In the library project, you can specify any library-specific ProGuard configuration in build.gradle, e.g.:

defaultConfig {
    consumerProguardFiles 'proguard-rules.txt'
}

该文件,然后在库AAR打包为 proguard.txt ,并自动在应用程序项目中应用。

This file is then packaged in the library aar as proguard.txt and automatically applied in the application project.

如果您的的启用ProGuard的库中的项目(也许是因为要分发的库),那么你还需要添加适当的配置来处理库。 Android的摇篮版本似乎并没有自动执行此操作。您可以:

If you do enable ProGuard in a library project (maybe because you want to distribute the library), then you also have to add the proper configuration for processing the library. The Android Gradle build doesn't seem to do this automatically. You can:

  1. 复制 Android的SDK /工具/ ProGuard的/例子/ library.pro ProGuard的-project.txt 的库项目。
  2. 取下样品输入/输出线 -injars -outjars -libraryjars -printmapping 从文件中。该摇篮生成过程会自动提供这些选项。
  3. 从库项目的build.gradle参考配置。
  1. Copy android-sdk/tools/proguard/examples/library.pro to proguard-project.txt in your library project.
  2. Remove the sample input/output lines -injars, -outjars, -libraryjars, -printmapping from the file. The Gradle build process automatically provides these options.
  3. Reference the configuration from the build.gradle of the library project.

启用/禁用ProGuard的独立的库项目和应用项目,我工作得很好。

Enabling/disabling ProGuard independently for the library project and for the application project works fine for me.

这篇关于Proguard的忽略库的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆