4

I'm trying to set the destiantion folder depening on Debug or release mode. But I not really succesfully. For debug and release it always goes to debug folder. And if I remove the debug config then it goes to release folder, but both of them (release and debug).

I guess I have to modify the Running configuration, but I'm not sure how to do it.

Any help?

gradle file:

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 18
        versionName "0.70"
    }
    signingConfigs {
        release {
            storeFile file("xxxx")
            storePassword "xxxx"
            keyAlias "xxx"
            keyPassword "xxxx"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            applicationVariants.all { variant ->
                def file = variant.outputFile
                variant.outputFile = new File("C:\\PATH_TO_FOLDER\\release", "name" + defaultConfig.versionName + ".apk")
            }
        }
        debug {
            applicationVariants.all { variant ->
                def file = variant.outputFile
                variant.outputFile = new File("C:\\PATH_TO_FOLDER\\debug", "name_DEBUG_" + defaultConfig.versionName + ".apk")
            }
        }

    }

}
Marcel
  • 2,094
  • 3
  • 23
  • 37

1 Answers1

3

Okey... I figure it out.

Not sure if it's the best solution but I check the name of the buildtype and then I set the output folder according to it.

buildTypes {
        release {
            signingConfig signingConfigs.release

        }
        applicationVariants.all { variant ->
            def file = variant.outputFile
            println "Build info: $variant.buildType"
            if (variant.buildType.name=="release") {
                println "Release mode"
                variant.outputFile = new File("C:\\PATH_TO_FOLDER\\verify", "app" + defaultConfig.versionName + ".apk")
            } else {
                variant.outputFile = new File("C:\\PATH_TO_FOLDER\\debug", "app_DEBUG_" + defaultConfig.versionName + ".apk")
            }
        }

    }
Marcel
  • 2,094
  • 3
  • 23
  • 37