Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

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

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

classpath 'com.android.tools.build:gradle:3.0.1'

And it's work fine. After I update to Android Studio 3.1 , as result I update Android Gradle Plugin :

classpath 'com.android.tools.build:gradle:3.1.0'

And now I get error in my app/build.gradle:

def releaseFileName = "${rootProject.name}_${defaultConfig.versionName}.apk"
outputFileName = new File(rootProject.projectDir.absolutePath + "/release", releaseFileName.toLowerCase())

Error:

Absolute path are not supported when setting an output file name

I need to put output apk (app-release.apk) in specific path in project. In folder MyProject/release/app-relese.apk. How I can do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just in case this helps, this error means that now it's not allowed to have absolute paths on anything related to the apk's file name. I can attach you my BEFORE and AFTER to achieve what I needed (to have the APK in the project/app/build/ folder:

BEFORE gradle 3.1.0

applicationVariants.all { variant ->
    variant.outputs.all { output ->
        outputFileName = new File(
                output.outputFile.parent,
                output.outputFile.name)
    }
}

IN or AFTER gradle 3.1.0

applicationVariants.all { variant ->
    variant.outputs.all { output ->
        outputFileName = new File(
                "./../../../../../build/",
                output.outputFile.name)
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...