Description:
My game made with Unity (2022.3.12f1) is on Google Play Store and it has "In App Update" implemented.
Problem:
When i update my game on Play Store to a newer version, my older version do not shows the "NEW version available" pop-up. But if i play in a development .apk with a lower version than PlayStore i am being able to see the UPDATE pop-up
Question:
Why is it working only in development?
My Code:
This "InAppUpdate" script is attached to an Empty Game Object in the main scene.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Google.Play.AppUpdate;
using Google.Play.Common;
public class InAppUpdate : MonoBehaviour
{
AppUpdateManager appUpdateManager;
void Start()
{
appUpdateManager = new AppUpdateManager();
StartCoroutine(CheckForUpdate());
}
IEnumerator CheckForUpdate()
{
PlayAsyncOperation<AppUpdateInfo, AppUpdateErrorCode> appUpdateInfoOperation = appUpdateManager.GetAppUpdateInfo();
// Wait until the asynchronous operation completes.
yield return appUpdateInfoOperation;
if (appUpdateInfoOperation.IsSuccessful)
{
var appUpdateInfoResult = appUpdateInfoOperation.GetResult();
// Creates an AppUpdateOptions defining an immediate in-app-update flow and its parameters.
var appUpdateOptions = AppUpdateOptions.ImmediateAppUpdateOptions();
StartCoroutine(StartImmediateUpdate(appUpdateInfoResult, appUpdateOptions));
}
}
IEnumerator StartImmediateUpdate(AppUpdateInfo appUpdateInfoResult, AppUpdateOptions appUpdateOptions)
{
// Creates an AppUpdateRequest that can be used to monitor the
// requested in-app update flow.
var startUpdateRequest = appUpdateManager.StartUpdate(
// The result returned by PlayAsyncOperation.GetResult().
appUpdateInfoResult,
// The AppUpdateOptions created defining the requested in-app update
// and its parameters.
appUpdateOptions);
yield return startUpdateRequest;
// If the update completes successfully, then the app restarts and this line
// is never reached. If this line is reached, then handle the failure (for
// example, by logging result.Error or by displaying a message to the user).
}
}
The error:
Exception: Field currentActivity or type signature not found UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.Boolean isStatic) (at :0) UnityEngine.AndroidJNIHelper.GetFieldID (System.IntPtr javaClass, System.String fieldName, System.String signature, System.Boolean isStatic) (at :0) UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at :0) UnityEngine.AndroidJNIHelper.GetFieldID[FieldType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at :0) UnityEngine.AndroidJavaObject._GetStatic[FieldType] (System.String fieldName) (at :0) UnityEngine.AndroidJavaObject.GetStatic[FieldType] (System.String fieldName) (at :0) Google.Play.Common.UnityPlayerHelper.GetCurrentActivity () (at Assets/GooglePlayPlugins/com.google.play.common/Runtime/Scripts/UnityPlayerHelper.cs:32) Google.Play.AppUpdate.Internal.AppUpdateManagerPlayCore..ctor () (at Assets/GooglePlayPlugins/com.google.play.appupdate/Runtime/Scripts/Internal/AppUpdateManagerPlayCore.cs:34) Google.Play.AppUpdate.Internal.AppUpdateManagerInternal..ctor () (at Assets/GooglePlayPlugins/com.google.play.appupdate/Runtime/Scripts/Internal/AppUpdateManagerInternal.cs:35) Google.Play.AppUpdate.AppUpdateManager..ctor () (at Assets/GooglePlayPlugins/com.google.play.appupdate/Runtime/Scripts/AppUpdateManager.cs:33) InAppUpdate.Start () (at Assets/Scripts/InAppUpdate.cs:14)
I tried with my InAppUpdate
script (Code shown above).