uni-app 官方不支持云打包时隐藏应用图标,需要通过离线打包后手动修改 AndroidManifest 替换或移除 intent‑filter 配置才能实现。
原理:删除 <category android:name="android.intent.category.LAUNCHER"/> 即可让应用不在启动器显示,但仍能通过调用包名来启动。
- 在 uni-app 项目根目录新建
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lalala.query">
<application>
<!-- 允许第三方调用,必须设置 exported="true" -->
<activity
android:name="io.dcloud.PandoraEntryActivity"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<data android:host="lalalaquery" android:scheme="query" />
</intent-filter>
</activity>
</application>
</manifest>
- 云打包完成后,将生成的 APK 重命名为
original.apk。 - 使用
apktool解包:
apktool d original.apk -o decoded
- 打开
decoded/AndroidManifest.xml,在PandoraEntryActivity所在<activity>下的<intent‑filter>中 移除或注释:
<category android:name="android.intent.category.LAUNCHER"/>
这样可以隐藏图标,避免在桌面或 app 抽屉显示启动入口。
- 重新打包:
apktool b decoded -o modified.apk
- 使用 uber‑apk‑signer 重新签名:
java -jar uber-apk-signer-1.3.0.jar \
-a modified.apk \
--ks my.keystore --ksAlias 别名 --ksKeyPass 密钥密码 --ksPass 证书密码 \
-o output-dir
- 通过命令测试启动:
adb -s 127.0.0.1:16384 shell am start -n com.lalala.query/io.dcloud.PandoraEntryActivity