Reputation: 45
I tried using the In App Update API from the PlayCore sdk, but after the app auto updates, it didn't restart. When reading the manual, it said if after the app updates and install and it didn't restart, you have to log the error. But when I add the log script for the error handler, it never did log anything.
Here's my code:
private IEnumerator CheckAppUpdate()
{
AppUpdateManager appUpdateManager = new AppUpdateManager();
PlayAsyncOperation<AppUpdateInfo, AppUpdateErrorCode> appUpdateInfoOperation = appUpdateManager.GetAppUpdateInfo();
// Wait until the asynchronous operation completes.
yield return appUpdateInfoOperation;
if (appUpdateInfoOperation.IsSuccessful)
{
var appUpdateInfoResult = appUpdateInfoOperation.GetResult();
if (appUpdateInfoResult.UpdateAvailability == UpdateAvailability.UpdateAvailable) {
updateAvailable = true;
AppUpdateOptions appUpdateOptions = AppUpdateOptions.ImmediateAppUpdateOptions();
yield return StartImmediateUpdate(appUpdateManager, appUpdateInfoResult, appUpdateOptions);
}
}
else
Debug.LogError($"Error:\n{appUpdateInfoOperation.Error}");
}
private IEnumerator StartImmediateUpdate(AppUpdateManager appUpdateManager, AppUpdateInfo updateInfo, AppUpdateOptions updateOptions)
{
var immediateUpdateRequest = appUpdateManager.StartUpdate(updateInfo, updateOptions);
yield return immediateUpdateRequest;
//If this Line is reached, the app didn't restart and that means the install failed
Debug.LogError("Install Update Error:\n" + immediateUpdateRequest.Error);
}
And as you can see from this screenshot of my Error Log, it never reached the Debug.LogError line.
PS. I'm using Unity 2020.38.3f and using the Developer Build Option so I can check the log in my editor after I build the apk.
Upvotes: 0
Views: 200
Reputation: 1
I hope you already found the solution and happy to see what you did. In your case, you may want to cast the appUpdateManager and set appUpdateManager = new AppUpdateManager() in Start() function instead of put it in the Coroutine(). This may solve your error (not so sure why it is related to "shader") then you will see the log from debugging.
Upvotes: 0