自从有了一个更新的答案之后已经有一段时间了,所以我想我会更新,因为对DexGuard的许可证文件设置进行了更改。
我刚刚从Android Studio版本从2.2.3更新到2.3,并将我的Gradle版本从2.14.1升级到3.3。在升级到摇篮3.3版,我收到了由OP记载了同样的错误:
Can't find a DexGuard license file.
You should place your license file dexguard-license.txt
1) in a location defined by the Java system property 'dexguard.license',
2) in a location defined by the OS environment variable 'DEXGUARD_LICENSE',
3) in your home directory,
4) in the class path, or
5) in the same directory as the DexGuard jar.
我DexGuard配置是工作得很好用摇篮版本2.14.1我dexguard-license.txt文件在同一目录作为DexGuard jar(建议#5)。
事实证明,对于DexGuard的文件规定如下:
Note: when using Gradle 3.1+, the license file will not be found anymore when placed in the same directory as the DexGuard plugin jar.
(来源:DexGuard 7.3.10文件 - >快速开始 - >设置许可文件)
我想将我的许可证文件保存在DexGuard jar相同的目录中,因此我实施了建议#1。
systemProp.dexguard.license=./app/libs/Dexguard_7_3_10
注意,我DexGaurd罐子和我dexguard-LICENSE.TXT文件位于以下目录::我通过添加下面一行到我的项目的gradle.properties文件,这样做{项目文件夹} /应用/ libs/DexGuard_7_3_10/
我采用这种解决方案,因为我不仅在本地构建,而且在Jenkins CI上构建。此解决方案使我无需在构建服务器本身上实施任何更改(即本地环境变量,将文件复制到服务器主目录或类路径选项)。我希望这可以帮助别人解决这个问题,并发现错误信息令人困惑。