Google Play 管理中心:免安装应用 APK 的包名应与应用的包名相同

Google Play Console: Package name of your Instant App APKs should be the same as your app's package name

我正在尝试使用 Google Play 控制台上传以开发我的即时应用程序,但它 returns 出现错误:您的即时应用程序 APK 的包名称应该是与您的应用程序包名称相同。

我还有一个功能调用 baseapkinstantApp 功能,每个人都有自己的 gradle 文件,apkinstantApp 实现了基本功能:

dependencies { implementation project(':base') }

我尝试通过 Build/Generate 签名的 APK 发布 .apk 构建...使用可安装应用程序的相同密钥,它创建一个 .apk 压缩文件

我不知道是什么原因导致 instantApp 和 apk 模块使用相同的基本功能,而且我不知道如何构建即时应用程序 APK

该 zip 文件是免安装应用程序。它可以包含多个 APK,一个用于每个功能模块,一个用于基础,可能还有一些配置 APK。如果它只包含一个 APK 也没关系。那将是基础。

zip 中的每个 APK 都有一个 AndroidManifest.xml,您可以使用 APK 分析器轻松查看。它们应该各自有一个 packageName,并且它们应该都匹配,那个值就是免安装应用程序的包名称。

已安装应用程序的包名称在通常的位置,在该 APK 的 AndroidManifest.xml。

samples 展示了构建项目的推荐方式,这将生成具有相同包名的即时应用和已安装应用。

检查您的基本模块是否引用了应用程序模块:

喜欢:

dependencies {
    application project(":installed")
    feature project(':app')
    feature project(":lite")
}

docs 中所述:

By setting this dependency, the app's applicationId for each flavor is appplied to the base feature module, which in turn propagates to all of the features in the project. This expression ensures that the installable APK and Instant App APKs have the same applicationId. If this is not set, the applicationId defaults back to the one defined in the base feature module manifest.