0

I have an app with multiple flavors where I'm using dexguard, and I've decided to set it up on Jenkins. Dexguard licenses are located in /app/flavor/ for eash license, but Jenkins always takes the license from the last flavor. The build fails with the error code:

The package name from the AndroidManifest.xml file [com.example.android.flavor1.something] doesn't match the package name [com.example.android.flavor6.something,com.example.android.flavor6.test,com.example.android.flavor6.something.prod,com.example.android.flavor6.test] from your DexGuard license [C:\Users\CurrentUser\AndroidStudioProjects\MyApp\flavor6\dexguard-license.txt]

I have tried renaming dexguard.license to dexguard-licenseX.txt (where X is the number of flavor) and setting in flavors build.gradle to look for that name, that couldn't even find the license file. I have also tried setting up the licence location in gradle.properties with systemProp.dexguard.licence=./flavor1.

I'm currently using

release {
     System.properties['dexguard.license'] = buildscript.sourceFile.parent
     proguardFiles getDefaultDexGuardFile('dexguard-release.pro'), 'dexguard-rules.pro', 'proguard-rules.pro'
}

And that works only if I try to build the last flavor, otherwise I have to copy dexguard-license to home folder (which isn't a problem locally, but it is a problem on Jenkins).

Is there a way to set up dexguard on jenkins ?

isaaaaame
  • 460
  • 4
  • 9

2 Answers2

3

dexguard-license1.txt will not be taken into account, start with dexguard-license2.txt if you have additional license files.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
  • ` 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 (not working in combination with Gradle v3.1+). ` @T. Neidhart – isaaaaame Jul 05 '19 at 07:53
0

Solved it: Added this code to build.gradle of every module:

def getCurrentModule() {
Gradle gradle = getGradle()
String  tskReqStr = gradle.getStartParameter().getTaskRequests().toString()

if(tskReqStr.indexOf( ":currentModule:" ) >= 0 )
    return ":currentModule:"
else
  {
    println "NO MATCH FOUND"
    return ""
  }
}

and this in buildTypes-release:

if (getCurrentModule() == ":currentModule:") {
            System.properties['dexguard.license'] = buildscript.sourceFile.parent
        }
        proguardFiles getDefaultDexGuardFile('dexguard-release.pro'), 'dexguard-rules.pro', 'proguard-rules.pro'
isaaaaame
  • 460
  • 4
  • 9