google / play-unity-plugins

The Google Play Plugins for Unity provide C# APIs for accessing various Play services
Other
426 stars 109 forks source link

[Play Asset Delivery] Google build and run option generates a build with a different signature #94

Open TutoMikDab opened 3 years ago

TutoMikDab commented 3 years ago

So far I have come across 2 different issues that lead to the same problem when using Google Play Asset Delivery plugin, I suspect that the issues arise due to the .apk (aab) signing process after the build is built by Unity (and then Play Asset Delivery plugin signs the build externally).

1st issue

Using Play Asset Delivery (Google -> Build and run) option I can't update my app, I have to uninstall it every time I want to test an update. This is troublesome when I want to test an update (for example testing backwards compatibility or bugs for an app install that already has saved progress). I get this error:

Installing app bundle failed: Failed to run 'E:/Programs/Unity/Unity/2019.4.5f1/Editor/Data/PlaybackEngines/AndroidPlayer\OpenJDK\bin\java.exe -jar "E:\Projects\ABC\Library\PackageCache\com.google.android.appbundle@1.3.0\Editor\Tools\bundletool-all.jar" install-apks --adb="E:/Programs/Unity/Unity/2019.4.5f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK\platform-tools\adb.exe" --apks="C:\Users\ABC\AppData\Local\Temp\play-unity-build\temp.apks"'
stdout:
04:50:04 E/SplitApkInstaller: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package XXX.XXX.XXX signatures do not match previously installed version; ignoring!

stderr:
The APKs have been extracted in the directory: C:\Users\ABC\AppData\Local\Temp\2605219721206710497
The APKs have been extracted in the directory: C:\Users\ABC\AppData\Local\Temp\2605219721206710497
[BT:1.2.0] Error: Installation of the app failed.
com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Installation of the app failed.
    at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
    at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:145)
    at com.android.tools.build.bundletool.commands.InstallApksCommand.lambda$execute$1(InstallApksCommand.java:165)
    at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:81)
    at com.android.tools.build.bundletool.device.AdbRunner.run(AdbRunner.java:43)
    at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:165)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:89)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)
Caused by: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package XXX.XXX.XXX signatures do not match previously installed version; ignoring!
    at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:91)
    at com.android.ddmlib.Device.installPackages(Device.java:928)
    at com.android.tools.build.bundletool.device.DdmlibDevice.installApks(DdmlibDevice.java:129)
    ... 6 more

exit code: 1

UnityEngine.Debug:LogError(Object)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleRunner:DisplayRunError(String, String) (at Library/PackageCache/com.google.android.appbundle@1.3.0/Editor/Scripts/Internal/BuildTools/AppBundleRunner.cs:108)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleRunner:RunBundle(String, BundletoolBuildMode) (at Library/PackageCache/com.google.android.appbundle@1.3.0/Editor/Scripts/Internal/BuildTools/AppBundleRunner.cs:65)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:RunBundle(String) (at Library/PackageCache/com.google.android.appbundle@1.3.0/Editor/Scripts/Internal/AppBundlePublisher.cs:211)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:HandleUpdate() (at Library/PackageCache/com.google.android.appbundle@1.3.0/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:354)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

2nd issue

I've recently added Google Sign In option into my app (https://github.com/googlesamples/google-signin-unity/). When using Google -> Build and run method, sign in with google doesn't work and I keep getting the infamous "Google.GoogleSignIn+SignInException" exception (sign in works perfectly fine when building normally (without Play asset delivery working), or if the build is uploaded to google play internal test track).

These 2 issues (that I know of) make testing my app a difficult and long process. Is there anything that can be done about this? Why does the signature differ when building through unity and building through Google -> build and run menu option?

I always build a signed .aab with a legitimate certificate that I use to upload to the store, development option is unchecked, so these 2 things are not the culprits.

TrueRaider commented 7 months ago

1st issue: Same problem with updating and after using fast-follow bundles in project. I tested update from internal testing, but release turned out to be non-working. All users with Samsung devices receive an error: INSTALL_FAILED_UPDATE_INCOMPATIBLE. Stranger Things!