Tuesday, 17 March, 2020 UTC


Summary

Running ARCore with Unity — Troubleshooting with Android phone + Mac

It was two days back when I first tried to install and run ARCore plugin/package with Unity. I went through the documentation and many great articles people had written for the same and it did help me reach somewhere. But, I still could not run my scene on my Android phone and after investigating half of the day, I was finally able to troubleshoot the issue. And as they say, “Journey is more important than the destination” — in this case, both were equally important.
I am documenting my small experience of a few hours where I created new issues to solve an existing one, in case it can prove valuable to people who are troubleshooting the process of running ARCore on their Macs coupled with their Android phones. It is a short step by step process (with optional references of issues) for running your simple AR application on your android device using Unity on Mac:
  1. Open Unity Hub and make sure you have at least 2019.2.21f1 version of Unity installed. Go to installs -> Add Modules -> Android Build Support. Do not forget to open the accordion and tick on Android SDK & NDK, Open JDK options.
Left: Step 1 for opening Unity and click on the three vertical dots of the Unity version, Right: Click on ‘Add Modules’Step 3: Tick on Android Build Support along with SDK, NDK, and JDK (Ignore iOS)
2. After launching your project, go to file → Build Settings. Go to Android → Switch platform.
If you don’t see the option of switching platform (Grayed out) do not worry, repeat step 1, get a compatible SDK, JDK and NDK, it won't be grayed out anymore.
Optional: It is possible when you do not have a compatible JDK or SDK in your Unity install. I had installed Android Studio separately and thought changing the location of SDK would work, it didn’t. In fact, you would see an install (download) button in the grayed out area which would install a Unity package for you (Not suggested). I would recommend using Unity’s recommended and compatible version by checking Step1 again.

Trending AR VR Articles:

1. Infographic: The Future of Virtual Reality
2. Mario Kart in a real vehicle with VR!
3. How XR Can Unleash Cognition
4. Oculus Go, the Nintendo Switch of VR
3. Connect your phone to your laptop using USB and become a developer on your phone settings. (See this for Pixel) Simply google this for your phone model. As you activate developer options, you can see your device in the Android Build settings.
Select your phone in this dropdown, rest keep as it is.
4. Go to Player Settings on the bottom left → Other Settings → Check AutoGraphics API and uncheck Vulkan Settings. In identification, make sure you have a distinct package name com.sglib.*** and Select Minimum API version according to the phone you’re using. I would say with the versions of SDK that we installed through Unity, keep it android 8 (Oreo, API level 26). Keep the target API level to “Automatic”.
Optional: If you make changes to the Minimum to a higher version, it requires you to go into SDK manager and install that version that might not exist in your SDK. If you are short of time, play safe and go with Oreo 8 with an updated Android phone. I tried changing the target API level, it threw errors so I kept it to recommended.
5. Your gut feeling would be to go to the “XR Settings” and switch on ARCore supported. Do not do that for now. I will come back to this. If you did not understand this point, you’re free to move on as if nothing happened.
Do not tick ARCore Supported
6. Now you can go to XR Plugin management → Create → tick Start and Stop Subsystems. (I am still investigating what happens if I do not do this)
7. Now the last step, go to Windows → Package Manager → Download AR Foundation Plugin (3.0.1) and ARCore XR Plugin (3.0.1) and please make sure you are not on 2.0.0 otherwise this won’t work on your mobile phone.
Optional: Firstly you can activate ARCore through a Unity package from the ARCore website and import it as a normal package. Then you do what is told not to do in Step5, i.e. activate ARCore support in XR settings.
Secondly, I did not know that Step7 does the same. If you do both of these, it might cause conflict while building. So, you might as well want to save yourself some time and follow Steps 5–7 and go smooth.
You do not need ARKit packages (Ignore in this article)
8. Go to File → Build Settings → Android → Select right scene to run on the top left → Build and Run
9. Automatic launch of an app on your phone post building, and you will be asked permission to the camera → give access and you can see your objects in the scene.
Optional: If you are not asked permission of the camera and an app launches with a black screen with the camera not working, I am certain it is the ARCore XR plugin upgrade that you need to check (Check step 7). If you are on 2.0.0, this is the issue you will encounter.
Something like this would happen in case of the error. Avoid this by checking Step 7.
10. If you are still facing some issue related to your JDK, SDK or NDK, Click on Unity → Preferences → External Tools → Make sure all of them are recommended ones.
Optional: If you are too eager to experiment with these by adding custom locations, uncheck them and add paths of your respective SDK, NDK, and JDK. Make sure then you have the right options selected in your player settings → Other Settings
Well, I hope these steps have saved you some time, if not, please let me know in comments. I am still learning and I would definitely like some feedback on this process — if it didn’t work for you or you would like to suggest some improvements for a better flow. (Though I helped 1 classmate through this process! :D)
I would like to thank my Professor Michael Nebling and my classmates for helping me in this class.

Don’t forget to give us your 👏 !

https://medium.com/media/1e1f2ee7654748bb938735cbca6f0fd3/href
Running ARCore with Unity — Troubleshooting with Android phone + Mac was originally published in AR/VR Journey: Augmented & Virtual Reality Magazine on Medium, where people are continuing the conversation by highlighting and responding to this story.