Wifi Direct Service Discovery Sample Errors

Dear community,

I have tried to integrate the "WiFi Direct Service Discovery Sample Unity Plug-in" from Magic Leap into a project and run it on a Magic Leap 2 or a Pixel 6a.

I am referring to the following repo: https://github.com/magicleap/wifi-direct-plugin-sample?tab=readme-ov-file#Using-the-Plug-in-in-a-Unity-project

I followed the steps listed in the README and was able to deploy the app to the devices (x64 or ARMv7). However, when running the app, I get the following exception on both the Magic Leap and the Pixel 6a:

Process: com.magicleap.samples.wifidirectsdactivity, PID: 17866
java.lang.NoSuchMethodError: No static method getAllowResizableWindow(Landroid/app/Activity;)Z in class Lcom/unity3d/player/MultiWindowSupport; or its super classes (declaration of 'com.unity3d.player.MultiWindowSupport' appears in /data/app/com.magicleap.samples.wifidirectsdactivity-dEBdrtxNKN-NWhmWXgbCcQ==/base.apk)
	at com.magicleap.samples.wifidirectsdactivity.UnityPlayerActivity.onStart(UnityPlayerActivity.java:89)
	at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1432)
	at android.app.Activity.performStart(Activity.java:7848)
	at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
	at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
	at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7357)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Why is it trying to execute "getAllowResizableWindow()"? And why is this method not available?

Unity 2022.3.26f1 and 2021.3.28f1:
ML2 OS version 1.7.0:
Built on Windows 11:

Any input is very welcome :slight_smile:

Thanks and regards,

Hi @julien.villiger

Are you using the ARR file from the sample or building a new version of your own ARR and integrating that to your project?

The "getAllowResizableWindow()" related exception that you are seeing appears to be coming from the UnityPlayerActivity class, which is a unity class that gets copied/pulled into a plug-in when creating one that extends the Unity Player Activity.

Finding good documentation on creating these kinds of Android plug-ins for Unity was challenging, however I do recall finding this video one of the more useful resources on the topic.

It might be that there is a mismatch between the version of UnityPlayerActivity class that was used in the sample vs the version of that same Unity class in the version of Unity that you are using for your project, and you may need to go through the same steps described in the video to copy the class from your target version of Unity and rebuild the plug-in for that Unity version.

You mention you are using two different versions of Unity, 2022.3.26f1 and 2021.3.28f1, can you elaborate a little on why you list two different version numbers? I believe the WiFi Direct sample was based on 2022.3.6f1, you might try test building your project against that particular version of Unity to see if you still encounter the same error.

Have you downloaded and tested the associated Shared Experience sample that demonstrates using the plug-in?

Does that build and run on your Magic Leap 2 without throwing the same error?

Happy to help you work through this and do what I can to help you get WiFi-Direct working in your project.

Hi @dlamb

Big thanks for your support.

ARR file
I'm using the ARR file from the sample, I didn't build anything myself. Yet.

Unity Version
I mentioned two Unity versions because I tried both. After running into issues with 2022.3.26f1 I thought maybe I have to downgrade it to match the samples version. But it's good to hear that you also used 2022.3.

Version mismatch
Might be, but I would be surprised, since we both used Unity 2022.3.x?

Shared Experience samle
I saw that example, but didn't have the chance to try it on my ML2.

Next steps

  • Going to build and try the Shared Experience sample
  • If it works: I could use this as a starting point
  • If not: I'm probably forced to re-build the plugin?

Thanks again and I'll let you know about my process.

Hi again @dlamb

I just tried running the WiFi-Direct-Shared-Experience-Sample App sample app and it's throwing the same error.

Could you maybe also check on your side?

@julien.villiger, will do,

Yesterday I cloned the shared experience sample and spun my wheels attempting to change to the .26 version of the Unity Editor but ran into a lot of issues with the associated Android modules not installing correctly, so I didn't make the progress on learning anything new about the issue that I had hoped.

Later today I will focus on confirming the the published shared sample builds and deploys in my environment, investigate further and report back to you.

Hi again @julien.villiger,

I can confirm that after removing a previously installed build of the Shared-Experience project from my ML2 device, and then installing the published APK from GitHub onto the device that the published version loads and also successfully connects to another ML2.

I then built and deployed from a new clone of the published Shared-Experience project to the same device and the app also loaded and successfully connects to another ML2. Note, I did stick to the same version of Unity 2022.3.6f1 of the published sample code and didn't change the version of the Unity Editor.

Can you try sideloading the published APK and let me know if that loads correctly or if it also crashes with the same error you have been seeing?

Hi @dlamb

I was able to successfully build, deploy and use the shared experience sample app with Unity 2022.3.6f1 on my Magic Leap 2 device. No errors. Also the pre-built APK works.

It seems that changing the Unity minor version from .6 to .26 causes the issue. We're currently looking into it and I'll let you know, once we have some insights. At the same time, if you could do some tests on your end, that would be extremely helpful.

Thanks so far for your support and kind regards.

1 Like

Hi @dlamb

We managed to create a working sample project with Unity 2022.3.26f1 by replacing UnityPlayerActivity.java and Classes.jar in the wifi-direct-plugin-sample project, building a new .aar and adding it to the Shared-Experience sample.

Have a nice weekend :slight_smile:

1 Like

Thanks @julien.villiger,

I am glad to hear that you were able to resolve the issue and appreciate the confirmation.

I have added additional information to the README in the hope that it may save someone from the same frustration in the future.


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.