5

I didn't find dexguard-license.txt file in dexguard.please help me in gradle setup in android studio here is my gradle console output

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.
Santhosh
  • 1,867
  • 2
  • 16
  • 23

4 Answers4

15

It's been a while since there was an updated answer, so I thought I'd update since there have been a change to DexGuard's license file setup.

I just updated from Android Studio version from 2.2.3 to 2.3 and also upgraded my Gradle version from 2.14.1 to 3.3. Upon upgrading to Gradle version 3.3, I received the same error that was documented by the 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.

My DexGuard configuration was working just fine using Gradle version 2.14.1 with my dexguard-license.txt file in the same directory as the DexGuard jar (suggestion #5).

It turns out that the documentation for DexGuard states the following:

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.

(Source: DexGuard 7.3.10 documentation -> Quick Start -> Setting up your license file)

I wanted to keep my license file in the same directory as the DexGuard jar, so I implemented suggestion #1. I did this by adding the following line to my project's gradle.properties file:

systemProp.dexguard.license=./app/libs/Dexguard_7_3_10

Note that my DexGaurd jar and my dexguard-license.txt files are located in the following directory: {project folder}/app/libs/DexGuard_7_3_10/

I went with this solution as I not only build locally but also on a Jenkins CI. This solution prevents me from having to implement any changes on the build server itself (i.e. local environment variable, copying files to server home directory, or class path options). I hope this helps someone else that stumbles upon this problem and finds the error message confusing.

Travis Yim
  • 384
  • 3
  • 14
  • Travis could you help me to understand what am I doing wrong? `Android Strudio 2.3.3` , `gradle 3.3`, my DexGuard path is : `(project name)\app\libs\DexGuard-8.0.14`, dexguard-license.txt path is : `(project name)\app\libs\DexGuard-8.0.14\lib\dexguard-license.txt` . Also I set `systemProp.dexguard.license=./app/libs/DexGuard-8.0.14/lib/dexguard-license.txt` in my `gradle.properties` file, but any way if I am trying to build project release mode, I get error `Error:Execution failed for task ':app:dexguardRelease'. >IOException: Please check your DexGuard license (see build log for details).` – Sirop4ik Oct 15 '17 at 12:59
  • @AlekseyTimoshchenko: It's been a while since I last modified this, but it looks like your systemProp.dexguard.license is incorrect. Instead of: systemProp.dexguard.license=./app/libs/DexGuard-8.0.14/lib/d‌​exguard-license.txt, try this: systemProp.dexguard.license=./app/libs/DexGuard-8.0.14/lib – Travis Yim Oct 18 '17 at 15:16
  • @TravisYim could you also paste the dexguard configuration you have please ! Its what is to be defined for `path` and `license` under `dexguard{ .. }` – shadygoneinsane Aug 16 '22 at 08:19
3

You should copy dexguard-license.txt file and dexguard.jar file to your home directory(: /user/ironman).

seyeon
  • 4,092
  • 2
  • 15
  • 12
2

The licence file is available to download once you've logged in on the account > files page on https://www.guardsquare.com

See this screen shot

scottyab
  • 23,621
  • 16
  • 94
  • 105
  • Thanks for the info, can you tell me the info about point(1)...location defined by the Java system property – Santhosh Jul 01 '15 at 07:06
  • So a JVM system property can be set on command line, although for Android likely you'll want to set in in gradle like this: `systemProperties['dexguard.license'] = './location/of/my/dexguard-license.txt'` – scottyab Jul 01 '15 at 10:47
  • where i have add this line in gradle file – Santhosh Jul 01 '15 at 13:31
  • hmm seems to be in `test` task, but why not just use one of the other methods? (3) or (5) seem very simple to achieve – scottyab Jul 03 '15 at 07:01
  • Make sure you use the same `package name/bundle id` as mentioned in the `license` file. It is case sensitive. – Nah Jan 26 '19 at 03:36
0

If you have dexguard-license.txt then you can define it under build.gradle as follows.

dexguard {

        version = '9.1.+'
  
        // Keep the license secure in your CD/CI
        **license = '/../YOURDIRECTORY/dexguard-license.txt'**
        configurations {
        release {
                ..
                ..
                
        }
        
    }
ozankyncu
  • 24
  • 3