美文网首页
AndroidStudios3.x遇到的坑

AndroidStudios3.x遇到的坑

作者: MIRROR1217 | 来源:发表于2018-12-14 10:21 被阅读0次

Gradle自定义apk名称报错

  • error:Cannot set the value of read-only property 'outputFile
applicationVariants.all { variant ->
    variant.outputs.each { output ->
    def fileName = "${variant.versionName}_release.apk"
    def outFile = output.outputFile
    if (outFile != null && outFile.name.endsWith('.apk')) {
        output.outputFile =newFile(outFile.parent, fileName)
    }  
}

outputFile变为只读,不能修改输出的名称所以报错。修改为:

    variant.outputs.all { output ->  // each 改为 all
    def fileName = "${variant.versionName}_release.apk"
    def outFile = output.outputFile
    if (outFile != null && outFile.name.endsWith('.apk')) {
        output.outputFileName = fileName  //  output.outputFile 改为 outputFileName 
    }    
}

把each修改为all,然后通过outputFileName修改生成apk的名称。此外,AS 3.0后打包完,除了apk包文件,还会多一个 output.json 参数文件。

  • error:Absolute path are not supported when setting an output file name

将”outputFile.parent” 修改为相对路径解决此问题,修改为 :
outputFileName = new File(“../../../release/”, fileName)

Gradle一些属性不能用

  • error:could not get unknown property 'bundleRelease' for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication

将bundleRelease修改为bundleReleaseAar

flavors报错

  • error:Error:All flavors must now belong to a named flavor dimension. Learn more at...
    原因就是使用了productFlavors分包,解决方法就是在build.gradle中的defaultConfig中添加一个flavorDimensions "1"就可以了

相关文章

  • AndroidStudios3.x遇到的坑

    Gradle自定义apk名称报错 error:Cannot set the value of read-only ...

  • 遇到的坑

    1.文字两端居中 2.多个异步请求的执行顺序 点击页面上一个按钮发送两个ajax请求时,这两个异步请求会同时发送,...

  • 遇到的坑

    1、 2、每次改完pom.xml后项目的 Language level都会变成7,使用了jdk8新功能的地方都会报...

  • 遇到的坑++

    1.加在一个view的时候报了一个异常 android.view.InflateException: Binary...

  • 遇到的坑

    键盘通知导致UI异常现象描述:本地详情页的inputView输入框,做了很多的功能,由多个view组成,这时点击微...

  • 遇到的坑

    第一次访问是 this page could not be found,刷新一下就好了 路径错误 多了一个 ‘/’

  • iOS开发中遇到过的坑

    iOS开发中遇到过的坑 iOS开发中遇到过的坑

  • display属性

    遇到的坑

  • IQKeyBoardManager 滑动删除text内容

    IQKeyBoardManager遇到的坑

  • Jenkins遇到的坑

    1、 自定义Shell 中使用sudo报错 - sudo:抱歉,您必须拥有一个终端来执行 sudo + '[' '...

网友评论

      本文标题:AndroidStudios3.x遇到的坑

      本文链接:https://www.haomeiwen.com/subject/kwuwhqtx.html