I am getting the following error message when my code executes:
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+d__2.MoveNext () (at Assets/____Script/IN APP UPDATE/inAppUpdate.cs:18) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) inAppUpdate:Start() (at Assets/____Script/IN APP UPDATE/inAppUpdate.cs:13)
The code in question is:
public class inAppUpdate : MonoBehaviour
{
AppUpdateManager appUpdateManager;
void Start()
{
StartCoroutine(CheckForUpdate());
}
IEnumerator CheckForUpdate()
{
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();
var appUpdateOptions = AppUpdateOptions.ImmediateAppUpdateOptions();
// Check AppUpdateInfo's UpdateAvailability, UpdatePriority,
// IsUpdateTypeAllowed(), etc. and decide whether to ask the user
// to start an in-app update.
StartCoroutine(StartImmediateUpdate(appUpdateInfoResult, appUpdateOptions));
}
else
{
// Log appUpdateInfoOperation.Error.
}
}
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).
}
}
Can anyone provide me with assistance in understanding the cause of the error?