使用HBuilderX 进行uniapp 打包Android APK 保姆教程
文章概览公司业务项目需要打包apk上传的应用市场,打包过程、上架过程、审核驳回等碰到的问题解决,以及操作步骤。
打包-设置
HBuilder X打包APK
基础设置
应用版本名称/应用版本号:设置必须比上一个版本的值高
https://img-blog.csdnimg.cn/img_convert/e565ba971ac7feff9dbc4d5fa6a9eebd.png
APP启动界面设置
https://img-blog.csdnimg.cn/img_convert/c321e71f9e265ba33443ba883bb2693d.png
Android启动界面设置,使用原生隐私政策提示框,会在项目根目录下创建生成一个文件androidPrivacy.json
登录后复制 {
"version" : "1",
"prompt" : "template",
"title" : "用户协议和隐私政策",
"message" : " 请你务必审慎阅读、充分理解“用户协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/> 你可阅读<a href=\"xxx\">《用户协议》</a>和<a href=\"xxx\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "同意并接受",
"buttonRefuse" : "暂不同意",
"hrefLoader" : "system",
"backToExit" : "false",
"second" : {
"title" : "确认提示",
"message" : " 进入应用前,你需先同意<a href=\"xxx\">《用户协议》</a>和<a href=\"xxx\">《隐私政策》</a>,否则将退出应用。",
"buttonAccept" : "同意并继续",
"buttonRefuse" : "退出应用"
},
"disagreeMode" : {
"support" : false,
"loadNativePlugins" : false,
"visitorEntry" : false,
"showAlways" : false
},
"styles" : {
"backgroundColor" : "#F1F1F1",
"borderRadius" : "5px",
"title" : {
"color" : "#000"
},
"buttonAccept" : {
"color" : "#000"
},
"buttonRefuse" : {
"color" : "#ccc"
},
"buttonVisitor" : {
"color" : "#aaa"
}
}
}
[*]1.
[*]2.
[*]3.
[*]4.
[*]5.
[*]6.
[*]7.
[*]8.
[*]9.
[*]10.
[*]11.
[*]12.
[*]13.
[*]14.
[*]15.
[*]16.
[*]17.
[*]18.
[*]19.
[*]20.
[*]21.
[*]22.
[*]23.
[*]24.
[*]25.
[*]26.
[*]27.
[*]28.
[*]29.
[*]30.
[*]31.
[*]32.
[*]33.
[*]34.
[*]35.
[*]36.
[*]37.
[*]38.
APP模块设置
这个需要根据自己的项目需求进行设置
https://img-blog.csdnimg.cn/img_convert/bcb0ce7890b15507dee798d9a98e8602.png
APP权限设置
登录后复制 <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
[*]1.
[*]2.
[*]3.
[*]4.
[*]5.
[*]6.
[*]7.
[*]8.
[*]9.
[*]10.
[*]11.
[*]12.
[*]13.
[*]14.
[*]15.
[*]16.
[*]17.
APP常用其它设置
有些应用市场targetSdkVersion版本有要求,需要在这里进行设置
https://img-blog.csdnimg.cn/img_convert/645578dabea0795dab573af78f590719.png
最好关闭使用广告标识(IDFA) 在上架应用市场的时候会被检测到
https://img-blog.csdnimg.cn/img_convert/cb197141d515d65b8fa4d7ec220b2ae4.png
源码视图
登录后复制 {
"name" : "",
"appid" : "",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : 2,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* 模块配置 */
"modules" : {
"Payment" : {}
},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>",
"<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>"
],
"targetSdkVersion" : 30
},
/* ios打包配置 */
"ios" : {
"dSYMs" : false,
"idfa" : false
},
/* SDK配置 */
"sdkConfigs" : {
"ad" : {},
"payment" : {
"alipay" : {
"__platform__" : [ "android" ]
}
}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
},
"splashscreen" : {
"useOriginalMsgbox" : true
}
}
},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true,
"appid" : ""
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2",
"h5" : {
"router" : {
"mode" : "history",
"base" : ""
}
},
"channel_list" : [
{
"id" : "chuizi",
"name" : "锤子应用市场"
},
{
"id" : "meizu",
"name" : "魅族应用市场"
}
]
}
/* ios打包配置 *//* SDK配置 */
[*]1.
[*]2.
[*]3.
[*]4.
[*]5.
[*]6.
[*]7.
[*]8.
[*]9.
[*]10.
[*]11.
[*]12.
[*]13.
[*]14.
[*]15.
[*]16.
[*]17.
[*]18.
[*]19.
[*]20.
[*]21.
[*]22.
[*]23.
[*]24.
[*]25.
[*]26.
[*]27.
[*]28.
[*]29.
[*]30.
[*]31.
[*]32.
[*]33.
[*]34.
[*]35.
[*]36.
[*]37.
[*]38.
[*]39.
[*]40.
[*]41.
[*]42.
[*]43.
[*]44.
[*]45.
[*]46.
[*]47.
[*]48.
[*]49.
[*]50.
[*]51.
[*]52.
[*]53.
[*]54.
[*]55.
[*]56.
[*]57.
[*]58.
[*]59.
[*]60.
[*]61.
[*]62.
[*]63.
[*]64.
[*]65.
[*]66.
[*]67.
[*]68.
[*]69.
[*]70.
[*]71.
[*]72.
[*]73.
[*]74.
[*]75.
[*]76.
[*]77.
[*]78.
[*]79.
[*]80.
[*]81.
[*]82.
[*]83.
[*]84.
[*]85.
[*]86.
[*]87.
[*]88.
[*]89.
[*]90.
[*]91.
[*]92.
[*]93.
[*]94.
[*]95.
[*]96.
[*]97.
[*]98.
[*]99.
[*]100.
[*]101.
[*]102.
[*]103.
[*]104.
[*]105.
[*]106.
[*]107.
[*]108.
[*]109.
[*]110.
[*]111.
[*]112.
[*]113.
[*]114.
[*]115.
[*]116.
[*]117.
[*]118.
[*]119.
[*]120.
[*]121.
[*]122.
[*]123.
[*]124.
[*]125.
[*]126.
[*]127.
[*]128.
[*]129.
[*]130.
[*]131.
[*]132.
[*]133.
[*]134.
[*]135.
[*]136.
[*]137.
[*]138.
[*]139.
[*]140.
云打包
发行-原生App-云打包
https://img-blog.csdnimg.cn/img_convert/5acef77dd63d1d686e55cb0d7f0d8d45.png
https://img-blog.csdnimg.cn/img_convert/68cbe3e7ae236fed648c1719ab888492.png
其中渠道打包,HBuilderx自身支持上图渠道包中未圈中的渠道,想自己添加渠道,需要在源码试图中添加,将下面的渠道代码放到源码视图的代码根目录中,可以看打包-设置-源码视图
登录后复制 "channel_list" : [
{
"id" : "chuizi",
"name" : "锤子应用市场"
},
{
"id" : "meizu",
"name" : "魅族应用市场"
}
]
[*]1.
[*]2.
[*]3.
[*]4.
[*]5.
[*]6.
[*]7.
[*]8.
[*]9.
[*]10.
上架审核
1、上架apk必须为最新版本
2、需要APP电子版权认证证书
3、APP完成备案
4、无三方产品素材
等等,根据上架审核的时候具体的驳回原因进行修改即可。
版本升级检测
参考文章:uniapp实现Android apk自动检测更新逼迫下载安装
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]