問題摘要
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/31672.html
標籤:Android
