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 错误

  • 相关阅读:
    Django的ORM
    Django model中设置多个字段联合唯一约束(多对多)
    Django 基本命令
    Django中使用Microsoft SQL SERVER
    pycharm django 再建一个app
    转载:Emmet使用手册
    线程示例(1)
    用socketserver实现简单的FTP
    python习题1-最大的不可支付邮资问题
    【实例:利用Django管理后台管理IP地址】(六)django_apscheduler实现定时检测IP使用情况
  • 原文地址:https://www.cnblogs.com/Rocky_/p/15632230.html
Copyright © 2011-2022 走看看