xamarin / XamarinComponents

Plugins for Xamarin
MIT License
1.99k stars 694 forks source link

Exception of type 'Google.AR.Core.Exceptions.UnsupportedConfigurationException' was thrown. #1247

Open cacaxiq opened 3 years ago

cacaxiq commented 3 years ago

I have trying to implement Augmented Faces using ArCore in Xamarin. But when I configure this:

        var config = new Google.AR.Core.Config(session);
        config.SetAugmentedFaceMode(AugmentedFaceMode.Mesh3d);

the app crash continuously

Follow the error: Google.AR.Core.Exceptions.UnsupportedConfigurationException: at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x0006e] in <1959115d56f8444789986cf39185638c>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue parameters) [0x0002a] in <1959115d56f8444789986cf39185638c>:0 at Google.AR.Core.Session.Configure (Google.AR.Core.Config config) [0x00031] in <6aeb54c0b6a04fb690d73af268b07cf6>:0 at Teste_ArCore.MainActivity.ConfigureSession () [0x00048] in /Users/carloshenriquegabriel/Projetos/Bee/Servdebt/xf-arcore-face/Teste_ArCore/MainActivity.cs:206 at Teste_ArCore.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0003e] in /Users/carloshenriquegabriel/Projetos/Bee/Servdebt/xf-arcore-face/Teste_ArCore/MainActivity.cs:45 at Android.App.Activity.n_OnCreate_Landroid_osBundle (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00010] in /Users/builder/azdo/_work/2/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.App.Activity.cs:2973 at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr,intptr) at com.google.ar.core.exceptions.UnsupportedConfigurationException at at java.lang.reflect.Constructor.newInstance0(Native Method) at at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at at com.google.ar.core.Session.throwExceptionFromArStatus(Session.java:16) at at com.google.ar.core.Session.nativeConfigure(Native Method) at at com.google.ar.core.Session.configure(Session.java:1) at at crc64c8c4577bb2b8a38b.MainActivity.n_onCreate(Native Method) at at crc64c8c4577bb2b8a38b.MainActivity.onCreate(MainActivity.java:46) at at android.app.Activity.performCreate(Activity.java:8126) at at android.app.Activity.performCreate(Activity.java:8098) at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310) at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3523) at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3710) at at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2139) at at android.os.Handler.dispatchMessage(Handler.java:106) at at android.os.Looper.loop(Looper.java:236) at at android.app.ActivityThread.main(ActivityThread.java:8047) at at java.lang.reflect.Method.invoke(Native Method) at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600) at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)

JorgeKleber commented 1 year ago

Hi @cacaxiq, set frontal camera in CameraConfigFilter before your code, for exemple:

var filter = new CameraConfigFilter(session);
filter.SetFacingDirection(CameraConfig.FacingDirection.Front);

var camConfig = session.GetSupportedCameraConfigs(filter);
session.CameraConfig = camConfig[0];

//your code here
var config = new Google.AR.Core.Config(session);
config.SetAugmentedFaceMode(AugmentedFaceMode.Mesh3d);

Probably you will can to use arcore with the frontal camera from device without exceptions, for now I'm looking for a solution that enable me to use the main camera (back camera).