'Failed to create AR session in AR supported devices
I am trying to implement AR Core feature in my app. This works fine in few devices (supports AR core - One plus 6T and Xiaomi Redmi Note 8). Doesn't work in few devices ( also supports AR core - One plus 7T and Samsung M31s).
It takes the user to play store to download "Google play services for AR". But the users are not seeing the update option in play store. Then it shows a toast message "Failed to create AR session"
The phones where AR core works fine has Android version 9 (Redmi Note 8) and 10 (Oneplus 6T).
The phones where AR core doesn't work has Android versions 11 (M31s and Oneplus 7T).
What could go wrong here.
I have added <uses-sdk tools:overrideLibrary="com.google.ar.sceneform.ux, com.google.ar.sceneform" />
in manifest.
Also added <meta-data android:name="com.google.ar.core" android:value="optional" />
in manifest
Why it doesn't work in few devices? Am I missing something? If more information is needed please mention in comments I will add it here. Thanks in advance
Solution 1:[1]
Thank you people for commenting your thoughts. I fixed it (temporarily) by pointing the target sdk to 29. Previously I was targeting 30. I will get this error again in future because I got a notification saying all apps should point 30 in future.
Edit 1 on 15 Apr 2022 - I fixes this issue by changing this com.google.ar:core:1.18.0 to com.google.ar:core:1.25.0. I changed the version from 18 to 25.
Solution 2:[2]
The solution does not look like the right direction, but works. Because the old dependencies have restriction to target version. So, in my case the same problem (update from 29 target api to 30 target api) had solved by set:
In file 'YourProject/app/build.gradle'
set the next dependecies for Android Target API 30 with the last of AR Sceneform Library:
android {
defaultConfig {
...
targetSdkVersion 30
...
}
}
dependencies {
...
api "com.google.ar.sceneform:core:1.17.1"
api "com.google.ar.sceneform.ux:sceneform-ux:1.17.1"
api "com.google.ar:core:1.22.0"
...
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 |