uni-app Hbulider X 打包问题
uni-app Hbulider X 打包问题
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Windows | 22H2 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Windows
HBuilderX类型:正式
HBuilderX版本号:4.29
手机系统:Android
手机系统版本号:Android 10
手机厂商:小米
手机机型:redmi k20
页面类型:vue
vue版本:vue2
打包方式:云端
项目创建方式:HBuilderX
示例代码:
"android" : {
"minSdkVersion" : 23,
"targetSdkVersion" : 31,
"autoSdkPermissions" : true,
"permissionExternalStorage" : {
"request" : "none",
"prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
}
}
HBuilderX 4.33.2024111702-alpha 已修复。
好的,谢谢
java.security.UnrecoverableKeyException: Password verification failed
请确认证书密码是否正确
我打正式包都没问题,设置"minSdkVersion" : 23,“targetSdkVersion” : 28,打包也没问题,设置minSdkVersion为26,targetSdkVersion为28之后打包就提示这个 java.security.UnrecoverableKeyException: Password verification failed
这应该不是我证书的问题吧,不然怎么打正式包
好的,谢谢
[Info] 正在制作apk安装包…
[Info] I: Using Apktool 2.6.1 on UNIDF09276_cm.apk
[Info] I: Loading resource table…
[Info] I: Decoding AndroidManifest.xml with resources…
[Info] I: Loading resource table from file: C:\Users\Administrator\AppData\Local\HBuilder X\AndroidPackWork\apktool\1.apk
[Info] I: Regular manifest package…
[Info] I: Decoding file-resources…
[Info] I: Decoding values / XMLs…
[Info] I: Copying raw classes.dex file…
[Info] I: Copying raw classes2.dex file…
[Info] I: Copying raw classes3.dex file…
[Info] I: Copying raw assets/39285EFA.dex file…
[Info] I: Copying assets and libs…
[Info] I: Copying unknown files…
[Info] I: Copying original files…
[Info] I: Copying META-INF/services directory
[Info] begin replace files to apk…
[Info] begin copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-hdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-hdpi/icon.png]…
[Info] copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-hdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-hdpi/icon.png] success.
[Info] begin copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-xhdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-xhdpi/icon.png]…
[Info] copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-xhdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-xhdpi/icon.png] success.
[Info] begin copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-xxhdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-xxhdpi/icon.png]…
[Info] copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-xxhdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-xxhdpi/icon.png] success.
[Info] begin copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-xxxhdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-xxxhdpi/icon.png]…
[Info] copy file[E:/work/HBuilderX/lilishop/lilishop-uniapp/unpackage/cache/wgt/UNIDF09276/.manifest/icon-android-xxxhdpi.png] to [C:/Users/Administrator/AppData/Local/HBuilder X/AndroidPackWork/cache/UNIDF09276/packge_cache/NONE/UNIDF09276_cm/res/drawable-xxxhdpi/icon.png] success.
[Info] begin update files to apk…
[Error] try compile package:0
[Info] I: Using Apktool 2.6.1
[Info] I: Copying C:\Users\Administrator\AppData\Local\HBuilder X\AndroidPackWork\cache__UNIDF09276\packge_cache__NONE__UNIDF09276_cm classes.dex file…
[Info] I: Copying C:\Users\Administrator\AppData\Local\HBuilder X\AndroidPackWork\cache__UNIDF09276\packge_cache__NONE\UNI__DF09276_cm classes2.dex file…
[Info] I: Copying C:\Users\Administrator\AppData\Local\HBuilder X\AndroidPackWork\cache\UNI__DF09276\packge_cache\NONE\UNI__DF09276_cm classes3.dex file…
[Info] I: Checking whether resources has changed…
[Info] I: Building resources…
[Error] W: C:\Users\Administrator\AppData\Local\HBuilder X\AndroidPackWork\cache\UNI__DF09276\packge_cache\NONE\UNI__DF09276_cm\AndroidManifest.xml:16: Tag <action> attribute name has invalid character ‘*’.
[Error] W: C:\Users\Admin
针对uni-app在HBuilder X中的打包问题,这里提供一些具体的代码案例和操作说明,帮助你更有效地解决打包过程中可能遇到的常见问题。
1. 配置manifest.json
首先,确保你的manifest.json
文件配置正确。这个文件包含了应用的基本信息、权限配置、模块配置等。以下是一个基本的配置示例:
{
"mp-weixin": { // 微信小程序配置示例
"appid": "your-app-id",
"setting": {
"urlCheck": false
}
},
"plus": {
"distribute": {
"google": {}, // Google Play配置
"apple": {} // iOS配置
},
"runtime": {
"splashscreen": {
"autoconvert": true,
"waiting": true
},
"permission": {
"REQUEST_INSTALL_PACKAGES": {} // 请求安装应用权限
}
}
},
"app-plus": {
"name": "你的应用名称",
"version": {
"name": "1.0.0",
"code": "100"
}
}
}
2. 条件编译
对于不同平台的打包,可以使用条件编译来区分代码。例如,为微信小程序和H5平台编写不同的代码:
// #ifdef MP-WEIXIN
console.log('这是微信小程序平台');
// #endif
// #ifdef H5
console.log('这是H5平台');
// #endif
3. 自定义打包脚本
在HBuilder X中,你可以通过vue.config.js
或webpack.config.js
来自定义打包过程。以下是一个简单的vue.config.js
示例,用于配置Webpack:
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},
plugins: [
// 自定义插件
]
},
chainWebpack: config => {
// 修改Webpack配置
config.module
.rule('scss')
.test(/\.scss$/)
.use('style-loader')
.loader('style-loader')
.end()
.use('css-loader')
.loader('css-loader')
.end()
.use('sass-loader')
.loader('sass-loader')
.end();
}
};
4. 打包命令
在HBuilder X中,通常通过图形界面进行打包操作,但你也可以在命令行中使用hbuilderx
命令进行打包。例如,打包为Android APK:
hbuilderx --publish android -p "你的项目路径"
确保你的环境变量和HBuilder X路径配置正确,以便命令行工具能够正常运行。
以上代码和配置示例应能帮助你解决uni-app在HBuilder X中的打包问题。如果遇到具体错误,建议查看HBuilder X的控制台输出或日志文件,以获取更详细的错误信息。