Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Morteza_dev's avatar
Morteza_dev
Honored Guest
1 year ago

Meta Voice SDK - NullPointerException with Looper on Activation

am encountering a NullPointerException in the Meta Voice SDK while attempting to activate AppVoiceExperience in my Unity project. The error occurs when the SDK tries to access Android's Looper.mQueue during initialization. I am on Mac.

I am developing for the Meat Quest 3. I have the Latest version of the Meta Voice SDK installed (v71) as well as the latest version of the Meta Core SDK. I do NOT have the Meta All in One SDK installed. I've set up all the Wit voice configuration files as well.

appVoiceExperience.Activate();

This code is causing the error. When I run it in game mode. I dont get an error

Here is the exact error:

2024-12-07 15:02:31.125 14100 14148 Error Unity AndroidJavaException: java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference
2024-12-07 15:02:31.125 14100 14148 Error Unity java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference
2024-12-07 15:02:31.125 14100 14148 Error Unity at android.os.Handler.<init>(Handler.java:257)
2024-12-07 15:02:31.125 14100 14148 Error Unity at android.os.Handler.<init>(Handler.java:162)
2024-12-07 15:02:31.125 14100 14148 Error Unity at com.oculus.assistant.api.voicesdk.core.VoiceSDKConnection$1.<init>(VoiceSDKConnection.java:54)
2024-12-07 15:02:31.125 14100 14148 Error Unity at com.oculus.assistant.api.voicesdk.core.VoiceSDKConnection.<init>(VoiceSDKConnection.java:54)
2024-12-07 15:02:31.125 14100 14148 Error Unity at com.oculus.assistant.api.voicesdk.logging.PlatformLogger$2.<init>(PlatformLogger.java:57)
2024-12-07 15:02:31.125 14100 14148 Error Unity at com.oculus.assistant.api.voicesdk.logging.PlatformLogger.<init>(PlatformLogger.java:56)
2024-12-07 15:02:31.125 14100 14148 Error Unity at com.oculus.assistant.api.unity.logging.UnityPlatformLoggerServiceFragment.createAndAttach(UnityPlatformLoggerServiceFragment.java:53)
2024-12-07 15:02:31.125 14100 14148 Error Unity at com.oculus.assistant.api.unity.logging.UnityPlatformLoggerServiceFragment.createAndAttach(UnityPlatformLogg

 



This happens regardless of whether I call Activate() in the Awake, Start, or through a delayed coroutine. The same error persists in all cases.

Here are some of my key observations:

  1.  Im actually also getting the exception before my script is even called.
  2. Awake in VoiceManager is successfully called, but Start encounters the NullPointerException.
  3. Even delaying the Activate() call with a coroutine or button click does not resolve the issue.
  4. The required permissions (RECORD_AUDIO, INTERNET, FOREGROUND_SERVICE) are all declared in the AndroidManifest.xml, and the app has been granted these permissions on the device.

4 Replies

  • What version of horizon OS is your Quest running? I heard that this issue might have been fixed in v72, but I still see it on my end unfortunately.

  • This seems to have helped, Claude helped me solve this issue.

      private void SetupDictation()
        {
            Debug.Log("[Dictation Setup] Starting setup process...");
           
            if (appDictationExperience == null)
            {
                Debug.LogError("[Dictation Setup] AppDictationExperience is null. Please assign it in the inspector.");
                return;
            }

            // Add platform check
            if (Application.platform == RuntimePlatform.Android)
            {
                try
                {
                    using (var looperClass = new AndroidJavaClass("android.os.Looper"))
                    {
                        // Ensure we have a Looper prepared
                        if (looperClass.CallStatic<AndroidJavaObject>("myLooper") == null)
                        {
                            looperClass.CallStatic("prepare");
                        }
                    }
                }
                catch (System.Exception e)
                {
                    Debug.LogError($"[Dictation Setup] Error preparing Android Looper: {e}");
                    return;
                }
            }

            // Add thread safety check
            if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(UnityEngine.Android.Permission.Microphone))
            {
                Debug.LogWarning("[Dictation Setup] Requesting microphone permission...");
                UnityEngine.Android.Permission.RequestUserPermission(UnityEngine.Android.Permission.Microphone);
                StartCoroutine(WaitForMicrophonePermission());
                return;
            }

            // Ensure we're on the main thread
            if (!UnityEngine.Application.isPlaying)
            {
                Debug.LogError("[Dictation Setup] Must be called during play mode");
                return;
            }

            // Check if the service is actually ready
            if (!appDictationExperience.Active)
            {
                Debug.LogWarning("[Dictation Setup] AppDictationExperience is not active. Waiting for activation...");
                StartCoroutine(WaitForDictationService());
                return;
            }

            Debug.Log($"[Dictation Setup] Status: Active={appDictationExperience.Active}, " +
                      $"UsePlatformIntegrations={appDictationExperience.UsePlatformIntegrations}, " +
                      $"HasPlatformIntegrations={appDictationExperience.HasPlatformIntegrations}, " +
                      $"MicPermission={Permission.HasUserAuthorizedPermission(Permission.Microphone)}");

            UnsubscribeFromEvents();
            SubscribeToEvents();
        }


  • Same here! The docs only have Play mode information, there's nothing about building the game. But apparently things can go wrong.
     
    Any Meta dev here?