0
\$\begingroup\$

I am pretty new to unity and augmented reality applications. I use unity 2019.4.4f1 and my project is very simple as you can see in the screenshot below:

enter image description here

I am using Wikitude plugin for image tracking and the image i am using as the marker is the Jack of Clubs card as you can see in the assets. The project works fine when i press play and use my laptop's webcam , but when i build the project for android (unity 2019 automatically uses Gradle to build the project) and install the .apk file in my android phone, all i see on my phone screen when i open the application is:

enter image description here

As you can see the phone camera doesn't work and it gets stuck in this screen. How should i fix it? Does it have to do something with Gradle? I haven't tried using unity version 2018 to build it using the "Internal" build option. Anyways that's just my own thought and i might be wrong, but the final question remains which is how this problem can be fixed?

By the way i don't build the .apk file directly from the unity engine. I use the export option in unity to get a gradle project folder then i use that in Android Studio to build the final .apk file. The reason that i don't use unity to build .apk is that it gives errors and doesn't work for me so this is the solution i found for it.

Update: I debugged the application and it seems that the application needs camera permission to work, this is my debugging log:

07-22 17:47:16.908: E/Unity(32483): On Camera Error
07-22 17:47:16.908: E/Unity(32483):         Error Code: 1000
07-22 17:47:16.908: E/Unity(32483):         Error Domain: com.wikitude.camera.android
07-22 17:47:16.908: E/Unity(32483):         Error Message: Permission denied. Make sure to have camera permissions before trying to access the camera.
07-22 17:47:16.908: E/Unity(32483):  
07-22 17:47:16.908: E/Unity(32483): (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

I'm pretty sure that it didn't ask for camera permission, how should i allow the permission if it's not asking?

\$\endgroup\$
  • \$\begingroup\$ We'll likely need more debugging info to be able to troubleshoot this effectively. Have you tried adding logging at each step, and checking the logs to see where the game gets stuck / what errors arose? \$\endgroup\$ – DMGregory Jul 22 at 12:02
  • \$\begingroup\$ @DMGregory I am very new to unity and i actually don't know how to do debugging, is there any way for me to learn how to do that? \$\endgroup\$ – Ali Nategh Jul 22 at 12:19
  • \$\begingroup\$ Did you start by searching "debug unity android build" and researching the resources that pulled up? \$\endgroup\$ – DMGregory Jul 22 at 12:24
  • \$\begingroup\$ @DMGregory I did now and i learned how to do debugging, now i have updated my question with the debug log. \$\endgroup\$ – Ali Nategh Jul 22 at 13:25
  • \$\begingroup\$ Looks like you should edit your question to show us the code that enables camera permission, and how you've structured your game to ensure that code runs before Wikitude tries to use the camera. \$\endgroup\$ – DMGregory Jul 22 at 13:31
0
\$\begingroup\$

Here's the documentation for requesting permissions. This is something you could have easily found with a web search.

I believe what you want in your code is this:

#if PLATFORM_ANDROID
    if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
    {
        Permission.RequestUserPermission(Permission.Camera);
    }
#endif
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.