Gradle版本4.6-设置输出文件名时不支持绝对路径 [英] Gradle Version 4.6 - Absolute path are not supported when setting an output file name
问题描述
我是Android的新手.因此,作为学习的一部分,我正在按照本教程制作图标包- https://blog.prototypr.io/how-to-create-an-android-icon-pack-app-ecb77811b938
当我将项目导入Android Studio时,出现以下错误- 我已经解决了该错误,因为那里已经提到了答案.之后,当我尝试构建项目时,出现以下错误-设置输出文件名时不支持绝对路径.
当我在Android Studio中打开文件时,它表明在以下代码中发生了错误:
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFileName = new File(
output.outputFile.parent, "MyIconPack-${variant.versionName}.apk")
}
}
所以我再次在这里搜索,发现了-解决方案
在更高版本的Gradle中,其工作原理与此类似:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def fileName = "${project.name}_${output.baseName}-${variant.versionName}.apk"
outputFileName = new File(output.outputFile.parent, fileName).getName()
}
}
因为output.outputFileName
是(或已成为)只读属性.
I am a newbie to Android. So as part of my learning I was following this tutorial to make an icon pack - https://blog.prototypr.io/how-to-create-an-android-icon-pack-app-ecb77811b938
When I imported the project to Android Studio, I got the following error - Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated I solved that error as the answer was already mentioned there. After that when I tried to build the project I got the following error - Absolute path are not supported when setting an output file name.
When I opened the file in Android Studio, it showed that the error was occuring in the following code:
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFileName = new File(
output.outputFile.parent, "MyIconPack-${variant.versionName}.apk")
}
}
So I searched here again and found this - android studio 3.1: build:gradle:3.1.0 - Absolute path are not supported when setting an output file name, but I was unable to understand the answer for that question.
So please help me to solve the error.
it works alike this with later version of Gradle:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def fileName = "${project.name}_${output.baseName}-${variant.versionName}.apk"
outputFileName = new File(output.outputFile.parent, fileName).getName()
}
}
because output.outputFileName
is (or had become) a read-only property.
这篇关于Gradle版本4.6-设置输出文件名时不支持绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!