zoukankan      html  css  js  c++  java
  • The application could not be installed: INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME

    问题摘要

    Installation did not succeed.
    The application could not be installed: INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME
    Installation failed due to: 'null'

    出现场景: 在变体里增加了 applicatinId 后缀 后安装时出现的。

    因为需求更改,需要增加变体,更改 applicationId ,所以在变体里使用了 applicationIdSuffix 来增加个后缀。

    defaultConfig {
        minSdkVersion config.minSdkVersion
        targetSdkVersion config.targetSdkVersion
        applicationId "com.skymxc"
        versionCode 1
        versionName "1.0.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
    }
    

    增加变体,更改后缀

    defaultConfig {
        minSdkVersion config.minSdkVersion
        targetSdkVersion config.targetSdkVersion
        applicationId "com.skymxc"
        versionCode 1
        versionName "1.0.0"
    
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
    }
    flavorDimensions 'cloud'
    productFlavors {
        oa41217 {
            dimension 'cloud'
            applicationIdSuffix "41217"
            versionCode 1
            versionName "1.0.0"
            
        }
    }
    

    然后在运行就出现上述问题了。

    出现原因: 增加的的后缀是纯数字

    applicationIdSuffix "41217"
    

    这个要增加的后缀不能是纯数字,要以字母开头。

    如何修复: 以字母开头。

    applicationIdSuffix "a41217"
    

    实际开发中肯定不能这么随便的加个 a ,自己酌情考虑吧。

    排查过程

    看提示是因为 解析包名出错了,所以就查看包名,刚开始觉得没什么问题。
    在开发者文档里看到了 applicationId 的命名规则:

    • 必须至少包含两段(一个或多个圆点)。
    • 每段必须以字母开头。
    • 所有字符必须为字母数字或下划线 [a-zA-Z0-9_]。

    猜测是不是后缀的值是不是也不能是纯数字,所以改了字母开头试了试。
    果然没有问题了。

    总结

    applicationIdSuffix 的值不能是纯数字,要以字母开头

    End

  • 相关阅读:
    Java编程规范
    java 编程军规
    数据库编程军规条例
    过滤重复记录(因为关联扩展表)
    根据子部门获取其到根部门的路径
    (原创)defparam的应用(Verilog,CPLD/FPGA)
    (原创)学习MCU的感悟_初级(MCU,经验)
    (原创)基于FPGA的调光流水灯(Verilog,CPLD/FPGA)
    (原创)基于MCU的频率可调,占空比可调的PWM实现(MCU,MCS-51/MSP430)
    (原创)动物照的情感与角度拍摄(摄影,欣赏)
  • 原文地址:https://www.cnblogs.com/skymxc/p/12380536.html
Copyright © 2011-2022 走看看