需求上只需要安卓端,暂无ios相关记录
1.开发、打包环境问题
使用框架是React,npm 20.3.0,java 17
2.各尺寸图标、启动页生成
根目录的resource文件夹下放入要使用的icon和splash文件
cordova-res android --skip-config --copy
我这边打出来的包默认走的mipmap-anydpi-v26这个配置,安装出来的自适应图标是歪的,所以我直接把这个文件夹删了,就走的正常mipmap-port-xx了
3.targetApi30打包问题
生成的apk安装时报错:ionic Targeting R+ (version 30 and above) requires the resources.arsc....
targetApi30改成28
把打包出来的unsign的apk包拷贝到build-tools/30.0.3的文件夹中,手动签名:
cd ~/Library/Android/sdk/build-tools/30.0.3
./zipalign -p -f -v 4 ./unsigned.apk ./signed.apk
./apksigner sign --ks xxx.keystore --ks-key-alias xxx.keystore ./signed.apk
4.Android Studio跑的模拟器,查看元素、请求
chrome中输入,在remote target中点击inspect
chrome://inspect/#devices
5.安卓默认阻止了http请求
CapacitorConfig中加:
server: {
androidScheme: 'http',
cleartext: true
}












网友评论