Search Unity

ARCore (Unity) Camera Permissions Dialog Never Shown

Discussion in 'AR' started by dentringer, Sep 29, 2017.

  1. dentringer

    dentringer

    Joined:
    Jun 1, 2013
    Posts:
    4
    When using ARCore in Unity, any apk that I publish doesn't ask for Camera Permissions.

    I've noticed that in the Android Studio AR Demo code that they were using a CameraPermissionsHelper class, and are calling the requestCameraPermissions() in the onResume(). This is easy for a project created in Android Studio, but doesn't help in Unity.

    The Unity ARCore SDK does contain a AndroidPermissionsManager, but, I'm not quite sure how to implement in Unity correctly.

    Has anyone solved or come across this issue at all?
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    Are you using the SessionComponent in ARCore? It manages the connection lifecycle, as well as requesting camera permission. You can see an example of its use in the HelloAR sample scene. See also SessionComponent.Connect in GoogleARCore/SDK/Scripts/SessionComponent.cs
     
  3. dentringer

    dentringer

    Joined:
    Jun 1, 2013
    Posts:
    4
    Yes, I attached a screenshot showing the SessionComponent setup.

    I see where the Connect method is calling the AndroidPermissionsManager.RequestPermission, not sure why the permissions dialog is never shown.

    Testing on a Pixel XL.

    I have to install and launch the apk, and manually toggle the camera permissions in order for the passthrough to show correctly.
     

    Attached Files:

  4. dentringer

    dentringer

    Joined:
    Jun 1, 2013
    Posts:
    4
    Looking thru logcat when running a fresh install, I was able to find this AndroidJavaException:

    09-28 21:02:43.753 6427 6443 E Unity : AndroidJavaException: java.lang.IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state.
    09-28 21:02:43.753 6427 6443 E Unity : java.lang.IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state.
    09-28 21:02:43.753 6427 6443 E Unity : at android.app.BackStackRecord.doAddOp(BackStackRecord.java:429)
    09-28 21:02:43.753 6427 6443 E Unity : at android.app.BackStackRecord.add(BackStackRecord.java:414)
    09-28 21:02:43.753 6427 6443 E Unity : at com.unity3d.player.UnityAndroidPermissions.RequestPermissionAsync(UnityAndroidPermissions.java:66)
    09-28 21:02:43.753 6427 6443 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    09-28 21:02:43.753 6427 6443 E Unity : at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    09-28 21:02:43.753 6427 6443 E Unity : at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source:151)
    09-28 21:02:43.753 6427 6443 E Unity : at android.os.Handler.dispatchMessage(Handler.java:101)
    09-28 21:02:43.753 6427 6443 E Unity : at android.os.Looper.loop(Looper.java:164)
    09-28 21:02:43.753 6427 6443 E Unity : at com.unity3d.player.UnityPlayer$c.run(Unknown Source:20)
    09-28 21:02:43.753 6427 6443 E Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x0008c] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNISafe.cs:24
    09-28 21:02:43.753 6427 6443 E Unity : at UnityEngine.AndroidJNISaf

    After granting camera permissions manually, this error does not appear.
     
    NewYorkHOK likes this.
  5. cabouse

    cabouse

    Joined:
    Feb 18, 2015
    Posts:
    1
    I'm having the exact same issue. I am using the pixel XL as well
     
    NewYorkHOK likes this.
  6. TWObitEDD

    TWObitEDD

    Joined:
    Sep 13, 2012
    Posts:
    3
    Having the same issue for the Pixel XL, haven't found a solution as far as release goes but have for testing's sake.

    You can open the system settings of the device and search for "Permissions" and manually allow Camera Access for both Tango and your app; this should allow you to work.
     
  7. Poulpizator

    Poulpizator

    Joined:
    Oct 4, 2017
    Posts:
    9
    Same issue too with a Pixel XL

    [Edit]Seems to be dependent of the Android SDK version, if you use the API26 there is the issue, but not with the API24
     
    Last edited: Oct 5, 2017
    ken1takahashi likes this.
  8. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Ditto here. No permissions popup on my Pixel XL. Took me a while to figure that out, and it was only after reading these forums that I realized I had to manually grant camera permissions after reading these forums. I thought it was broken at first.
     
  9. Daevin

    Daevin

    Joined:
    Jun 1, 2017
    Posts:
    11
    Same issue here, on a Pixel.

    I disagree*, I have Minimum API Level set to API24 and I have this issue.

    *Note: I am, however, targeting "Automatic (highest installed)", though he list only goes up to 25.
     
  10. faxedhead

    faxedhead

    Joined:
    Dec 21, 2014
    Posts:
    3
    Same here on Pixel 2 XL. When I check 'ARCore Supported' under XR Settings, no permissions are requested on launch of the app and inspection of temp/staging/androidmanifest.xml shows this is probably the cause:

    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />

    When 'ARCore Supported' is not checked, permissions prompt is shown correctly.

    I put a copy of this AndroidManifest.xml file in Assets/Plugins/Android/ folder with the value changed to false, but unfortunately the app just crashes on launch failing to find the launcher activity class. Any tips on how to override this value?
     
  11. NewYorkHOK

    NewYorkHOK

    Joined:
    Oct 13, 2017
    Posts:
    5
    Same, on a pixel, is there any fix for this?
     
  12. teodor440

    teodor440

    Joined:
    Jul 28, 2015
    Posts:
    1
    Might try to check the mark under File -> Build settings -> Player Settings -> XR settings -> AR core supported