Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting runtime exception #2

Open
gb-chen opened this issue Jan 27, 2024 · 3 comments
Open

Getting runtime exception #2

gb-chen opened this issue Jan 27, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@gb-chen
Copy link

gb-chen commented Jan 27, 2024

While launching my unity game on an android device, I get a runtime exception:
Error

Environment

  • play-install-referrer-unity plugin version 3.0.0.
  • Unity IDE version 2021.3.32f1.
  • Android API 33
  • Device name and model Pixel 4a
@gb-chen gb-chen added the bug Something isn't working label Jan 27, 2024
@gb-chen
Copy link
Author

gb-chen commented Jan 28, 2024

Interestingly, I tried building a development build in unity, and when running on my phone, the exception did not occur. It happens only for release build.

@nivedhKA
Copy link

Same issue. Did you found any workaround ? @gb-chen

@nivedhKA
Copy link

nivedhKA commented Aug 14, 2024

Well ! Found a one soluation for it and it's working. You need to follow below steps for it

  1. upgrade google play install referrer library version https://developer.android.com/google/play/installreferrer/library

  2. find the file PlayInstallReferrerAndroid.cs and update the code of this function GetInstallReferrerClient() as given below :


  private static AndroidJavaObject GetInstallReferrerClient()
        {
            if (ajoInstallReferrerClient == null)
            {
                AndroidJavaObject ajoCurrentActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
                AndroidJavaClass ajcInstallReferrerClient = new AndroidJavaClass("com.android.installreferrer.api.InstallReferrerClient");
                AndroidJavaObject ajoBuilder = ajcInstallReferrerClient.CallStatic<AndroidJavaObject>("newBuilder", ajoCurrentActivity);
                ajoInstallReferrerClient = ajoBuilder.Call<AndroidJavaObject>("build");
            }

            if (installReferrerResponseCodes == null)
            {
                installReferrerResponseCodes = new Dictionary<int, string>();
                AndroidJavaClass ajcResponse = new AndroidJavaClass("com.android.installreferrer.api.InstallReferrerClient$InstallReferrerResponse");
                installReferrerResponseCodes.Add(ajcResponse.GetStatic<int>("OK"), "OK");
                installReferrerResponseCodes.Add(ajcResponse.GetStatic<int>("FEATURE_NOT_SUPPORTED"), "FEATURE_NOT_SUPPORTED");
                installReferrerResponseCodes.Add(ajcResponse.GetStatic<int>("SERVICE_UNAVAILABLE"), "SERVICE_UNAVAILABLE");
                installReferrerResponseCodes.Add(ajcResponse.GetStatic<int>("DEVELOPER_ERROR"), "DEVELOPER_ERROR");
                installReferrerResponseCodes.Add(ajcResponse.GetStatic<int>("SERVICE_DISCONNECTED"), "SERVICE_DISCONNECTED");
            }

            return ajoInstallReferrerClient;
        }

Go Cheer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants