在android studio中设置dexguard许可证文件

San*_*osh 3 android android-studio dexguard

我没有在dexguard.please中找到dexguard-license.txt文件帮助我在android studio中进行gradle设置这里是我的gradle控制台输出

Executing tasks: [:app:assembleDebug]
.....
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.
Run Code Online (Sandbox Code Playgroud)

Tra*_*Yim 13

已经有一段时间了,因为有一个更新的答案,所以我想我会更新,因为DexGuard的许可文件设置已经更改.

我刚刚从Android Studio版本从2.2.3更新到2.3,并且还将我的Gradle版本从2.14.1升级到3.3.升级到Gradle版本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.
Run Code Online (Sandbox Code Playgroud)

我的DexGuard配置使用Gradle版本2.14.1与我的dexguard-license.txt文件在与DexGuard jar相同的目录中工作得很好(建议#5).

事实证明,DexGuard的文档说明如下:

注意:使用Gradle 3.1+时,当与DexGuard插件jar放在同一目录中时,将不再找到许可证文件.

(来源:DexGuard 7.3.10文档 - >快速入门 - >设置许可证文件)

我想将我的许可证文件保存在与DexGuard jar相同的目录中,因此我实现了#1的建议.我通过在我的项目的gradle.properties文件中添加以下行来完成此操作:

systemProp.dexguard.license=./app/libs/Dexguard_7_3_10
Run Code Online (Sandbox Code Playgroud)

请注意,我的DexGaurd jar和我的dexguard-license.txt文件位于以下目录中:{project folder}/app/libs/DexGuard_7_3_10 /

我选择了这个解决方案,因为我不仅在本地构建,而且还在Jenkins CI上构建.此解决方案使我无需在构建服务器本身上实现任何更改(即本地环境变量,将文件复制到服务器主目录或类路径选项).我希望这可以帮助其他人偶然发现这个问题,并发现错误信息令人困惑.