安装两个版本的 apk(具有不同的 applicationIds)

Install two versions of an apk (with different applicationIds)

我需要在 android 项目中更改多少才能将其安装为新应用程序?

我认为更改 build.gradle 文件中的 applicationId 就足够了,但我无法在不卸载第一个版本的情况下安装应用程序的第二个版本。在 Play 商店中我得到 error 910error -505 并且在手动安装时我得到:

Installation failed with message Failed to finalize session : INSTALL_FAILED_CONFLICTING_PROVIDER: Package couldn't be installed in /data/app/net.mindlevel-1: Can't install because provider name net.mindlevel (in package net.mindlevel) is already used by net.veglevel. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.

我是否也必须更改 AndroidManifest.xml 中的包名称?

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.mindlevel">

如果我改变了它,我必须改变每个源文件才能使用那个包,对吗?

在您的清单中,有一个带有硬编码 android:authorities 属性的 <provider> 元素。这需要更改以及您的 applicationId,因为每个唯一授权只能安装一个提供程序。