Gradle 3.0 BuildException cannot create directory

后端 未结 4 880
栀梦
栀梦 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 13:55

    I am building same app with Android Studio 3.0 on both Linux or Windows. After upgrading to Gradle 3.0.1, I had a similar issue on Windows, while it was working fine on Linux:

    Error:Execution failed for task ':smsreminder:packageDebug'. > Cannot create directory C:\Users\Florent\AndroidStudioProjects\MyApp\myapp\build\outputs\apk\debug\C:\Users\Florent\AndroidStudioProjects\MyApp\myapp\build\outputs\apk\debug

    And thanks to above answer from Leo, I made this more friendly apk name:

    outputFileName = "${variant.name}-${variant.versionName}.apk"
    => produces: debug-x.y.apk
    
    outputFileName = output.outputFile.name + ".${variant.versionName}.apk"
    => produces: MyAppName.x.y.apk
    

    Otherwise, I found this working too if one want to keep default :

    if (org.gradle.internal.os.OperatingSystem.current().windows)
                outputFileName = "${variant.name}-${variant.versionName}.apk"
            else
                outputFileName = new File(output.outputFile.parent, outputFileName.replace(output.outputFile.name, defaultConfig.applicationId + ".apk"))
    

提交回复
热议问题