android studio 3.1: build:gradle:3.1.0 - Absolute path are not supported when setting an output file name

后端 未结 7 944
囚心锁ツ
囚心锁ツ 2020-12-05 19:32

When I use Android Studio 3.0 and I use the next version of Android Gradle Plugin in project/build.gradle:

cl         


        
7条回答
  •  青春惊慌失措
    2020-12-05 19:34

    I think using "./../../../" is bad solution... I use common gradle script for several projects and I want to make code to be independency from depth of output dir.

    After some researching I found this solution for gradle plugin 3.1.2:

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def relativeRootDir = output.packageApplication.outputDirectory.toPath()
                     .relativize(rootDir.toPath()).toFile()
            output.outputFileName = new File( "$relativeRootDir/release", newOutputName)
        }
    }
    

提交回复
热议问题