The application could not be installed: INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME
程序员文章站
2022-06-07 23:42:23
...
问题摘要
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
微信扫一扫,关注我的公众号
推荐阅读
-
详细解决:The application could not be iinstalled :INSTALL_FAILED_CONFLICTING_PROVIDER
-
The application could not be installed: INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME
-
Application not installed!可能是一个bug,关于SHA1-Digest Android
-
Application not installed!可能是一个bug,关于SHA1-Digest Android
-
详细解决:The application could not be iinstalled :INSTALL_FAILED_CONFLICTING_PROVIDER
-
部署heroku up出现Application error An error occurred in the application and your page could not be ser
-
启动Tomcat报错: this web application instance has been stopped already. Could not load...
-
解决:This application failed to start because it could not find or load the Qt platform plugin “xcb“
-
This application failed to start because it could not find or load the Qt platform plugin "dxcb" in
-
This application failed to start because it could not find or load the Qt platform plugin "xcb".