Game Development Asked by Ali Nategh on October 2, 2020
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:
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:
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?
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
Correct answer by Kevin on October 2, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP