Gradle 3.0 BuildException cannot create directory

后端 未结 4 860
栀梦
栀梦 2020-12-30 13:01

I\'m on windows and updated to Android Studio (AS) 3.0 RC1. When I try to built our project with gradle via AS or terminal it stops, the Stacktrace is at the end. The weird

4条回答
  •  一生所求
    2020-12-30 14:01

    With the stable release of Android Studio 3.0 I digged a little deeper. Turns out our script for naming the APK didn't work, but was only breaking on Windows.

    Old Script:

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")
                output.outputFile = new File(outputFile.parent, fileName)
            }
        }
    }
    

    Fixed Script:

    applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${variant.name}-${variant.versionName}.apk"
        }
    }
    

提交回复
热议问题