artoolkitx / arunityx

artoolkitX for Unity, providing high-performance video acquisition, marker and texture tracking and full Unity Editor support
https://www.artoolkitx.org/
Other
43 stars 22 forks source link

Unable to Run examples on Android: #62

Closed SimonDarksideJ closed 1 year ago

SimonDarksideJ commented 1 year ago

When built for Android, running any of the example scenes on an Android device only results in the following errors:

2023/05/10 15:47:25.371 26967 26988 Info Unity ARController: Error starting running
2023/05/10 15:47:25.386 26967 26988 Info Unity ARController: Starting AR.
2023/05/10 15:47:25.386 26967 26988 Info Unity ARController: Render device: Vulkan 1.1.0 [0x00800000], using Unity texturing.
2023/05/10 15:47:25.387 26967 26988 Info Unity ARController: Starting artoolkitX video with vconf '-module=Android -native -prefer=closestpixelcount -width=1280 -height=720 -cachedir="/storage/emulated/0/Android/data/com.UnityTechnologies.com.unity.template.urpblank/cache"'.
2023/05/10 15:47:25.387 26967 26988 Info libAR [info] Starting...
2023/05/10 15:47:25.387 26967 26988 Info libAR [info] Setting video configuration '-module=Android -native -prefer=closestpixelcount -width=1280 -height=720 -cachedir="/storage/emulated/0/Android/data/com.UnityTechnologies.com.unity.template.urpblank/cache"'.
2023/05/10 15:47:25.387 26967 26988 Info libAR [info] Opening artoolkitX video using configuration '-module=Android -native -prefer=closestpixelcount -width=1280 -height=720 -cachedir="/storage/emulated/0/Android/data/com.UnityTechnologies.com.unity.template.urpblank/cache"'.
2023/05/10 15:47:25.387 26967 26988 Info libAR [info] Using supplied video config "-module=Android -native -prefer=closestpixelcount -width=1280 -height=720 -cachedir="/storage/emulated/0/Android/data/com.UnityTechnologies.com.unity.template.urpblank/cache"".
2023/05/10 15:47:25.395 26967 26988 Debug VendorTagDescriptor addVendorDescriptor: vendor tag id 14172875900359437128 added
2023/05/10 15:47:25.403 26967 26988 Error ACameraManager openCamera: connect camera device failed: Status(-8, EX_SERVICE_SPECIFIC): '1: validateClientPermissionsLocked:1547: Caller "" (PID 10429, UID 26967) cannot open camera "0" without camera permission'
2023/05/10 15:47:25.404 26967 26988 Error libAR [error] status == ACAMERA_OK
2023/05/10 15:47:25.404 26967 26988 Error libAR [error] Failed to open camera.
2023/05/10 15:47:25.404 26967 26988 Info libAR [info] Using supplied video config "-module=Android -native -prefer=closestpixelcount -width=1280 -height=720 -cachedir="/storage/emulated/0/Android/data/com.UnityTechnologies.com.unity.template.urpblank/cache"".
2023/05/10 15:47:25.405 26967 26988 Error libAR [error] ar2VideoOpen: Error: module "Android" requires ar2VideoOpenAsync.
2023/05/10 15:47:25.405 26967 26988 Error libAR [error] Error: unable to open connection to camera using configuration '-module=Android -native -prefer=closestpixelcount -width=1280 -height=720 -cachedir="/storage/emulated/0/Android/data/com.UnityTechnologies.com.unity.template.urpblank/cache"'.
2023/05/10 15:47:25.405 26967 26988 Error libAR [error] Unable to open video source.

In the scene, you are simply presented a box which states no camera was found.

The error prevents any other scripts from running.

SimonDarksideJ commented 1 year ago

On further investigation, this is caused by the lack of Android permissions for access to the Camera.

Manually updating the Unity AndroidManifest resolves the startup issue, but identifies another issue #63

The ARUnityX should manage, resolve and ensure the correct permissions are available and accepted by the user on startup.