zoukankan      html  css  js  c++  java
  • Cannot set the value of readonly property ‘outputFile‘ for ApkVariantOutputImpl_Decorated

    gradle升级后,之前的打包生成apk并重命名代码出现了问题,经查一共有2个地方要修改,下边代码是修改前:

     1     applicationVariants.all { variant ->
     2         variant.outputs.each { output ->
     3             def environment = 'TUI';
     4             def oldFile = output.outputFile
     5             if (variant.buildType.name == 'release') {
     6                 def releaseApkName = 'PORSCHE_'+ defaultConfig.versionName + '_' +releaseTime()+ '_'+environment+'_release.apk'
     7                 output.outputFile = new File(oldFile.parent, releaseApkName)
     8             } else {
     9                 def debugApkName = 'PORSCHE_' + defaultConfig.versionName + '_' /*+ releaseTime()+ '_'*/+environment+'_debug.apk'
    10                 output.outputFile = new File(oldFile.parent, debugApkName)
    11             }
    12         }
    13     }

    这个是修改后:

     1 applicationVariants.all { variant ->
     2         variant.outputs.each { output ->
     3             def environment = 'TUI';
     4             def oldFile = output.packageApplication.outputDirectory.toPath()
     5                     .relativize(rootDir.toPath()).toFile()
     6             if (variant.buildType.name == 'release') {
     7                 def releaseApkName = 'PORSCHE_'+ defaultConfig.versionName + '_' +releaseTime()+ '_'+environment+'_release.apk'
     8                 output.outputFileName = new File(oldFile.parent, releaseApkName)
     9             } else {
    10                 def debugApkName = 'PORSCHE_' + defaultConfig.versionName + '_' /*+ releaseTime()+ '_'*/+environment+'_debug.apk'
    11                 output.outputFileName = new File(oldFile.parent, debugApkName)
    12             }
    13         }
    14     }

    第一处:output.outputFile = 改成 output.outputFileName =

    第二处:def oldFile = output.outputFile 改成 output.packageApplication.outputDirectory.toPath()
    .relativize(rootDir.toPath()).toFile()

    否则就会报 Absolute path are not supported when setting an output file name 错误

  • 相关阅读:
    CEAA自动汇编脚本常用命令
    PIC之拉电流和灌电流
    CHARRANGE 结构
    汇编中的lodsb和stosb、lodsd和stosd指令
    汇编中的STOSB与STOSD指令
    汇编中的CLD指令
    SQL中distinct的用法
    SQL union介绍
    【项目排期】测试排期问题思考
    SQL join的介绍
  • 原文地址:https://www.cnblogs.com/Rocky_/p/15632230.html
Copyright © 2011-2022 走看看