签署 App Bundle 基本模块和动态功能模块

Signing The App Bundle Base Module And Dynamic Feature Module

在App Bundle的Google官方指南中:https://developer.android.com/guide/app-bundle/configure#base_build_config说签名信息只需要在基础模块build.config文件中指定。动态模块签名信息与基本模块一起使用。

我正在使用我自己的密钥库文件,所以我只在基本模块中包含签名配置。但是,当我在设备上构建和 运行 应用程序时,它总是弹出错误:

Installation failed with message Failed to finalize session : INSTALL_FAILED_INVALID_APK: /data/app/vmdl538875391.tmp/1_feature_-debug signatures are inconsistent. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.

当我在动态模块中包含签名信息时,错误消失了。 那么这是否与官方指南冲突?还是我这里做错了什么?

这样做

  1. 菜单"Build"

  2. 运行 "Rebuild Project".

然后 运行 设备或​​模拟器上的应用程序

或者如果上述解决方案不起作用。

那就试试这个

在 Android Studio 中禁用 Instant 运行,然后 Clean、Rebuild 和 运行, 它应该可以解决这个问题。

问题是由“编辑配置”中的设置引起的。为了仅在捆绑包的基本模块中包含签名信息,我需要选择 'APK from app bundle',而不是 'default APK'。否则,Android Studio 将使用签名信息而不是捆绑包对 APK 进行签名。