Unity + ARCORE DllNotFoundException: arcore_unity_api - arcore

I tried to run the arcore samples for unity as described on the following page: https://developers.google.com/ar/develop/unity/quickstart-android
But it doesn't work. The app starts and it is searching for the planes, but the camera feed is black. In the logcat there is the following exception:
DllNotFoundException: arcore_unity_api
at (wrapper managed-to-native) GoogleARCoreInternal.ARPrestoCallbackManager/ExternApi:ArCoreUnity_setArPrestoInitialized (GoogleARCoreInternal.ARPrestoCallbackManager/EarlyUpdateCallback)
at GoogleARCoreInternal.ARPrestoCallbackManager.InitializeIfNeeded () [0x00000] in <filename unknown>:0
at GoogleARCoreInternal.ARCoreAndroidLifecycleManager.CreateSession (GoogleARCore.ARCoreSession sessionComponent) [0x00000] in <filename unknown>:0
at GoogleARCore.ARCoreSession.Start () [0x00000] in <filename unknown>:0
I also tried the plain android samples, which work fine. What could be the issue that it doesn't work with unity?

I migrated back to Unity 2018.x to 2017.4.6f => now it works

The message is clear, Unity can't find the ARCore dll.
If you are using Unity Assembly Definitions
(which is a good thing to consider), you need to verify that the ARCore dll is being referenced correctly.
I solved this by putting a reference in my "main" .asmdef file to the .asmdef file from the ARCore folder (where the dll file is). (in my case Unity lost this reference by some odd reason)
If you are not using Assembly Definitions (it could be a good time to start), it could be interesting to double-check if you have the ARCore installed correctly in your project and if you have 'ARCore Support' enabled.
EDIT -> Project Settings (Android Tab) -> XR Settings, and check the box for "ARCore Supported" (see screenshot)

Related

JIT issues with IOS Xamarin SQLite

So I have some classes that I have been storing in a local SQLite DB in a Xamarin Forms application. Works fine on UWP, Android, and iOS except for Release on a physical device. Keep getting JIT warnings. I've tried removing linking various ways to ensure it's getting compiled but no dice. The root of the issue seems to be within the usage of SQLite-Net-pcl nuget library. Does anyone have advice on how to ensure that code has been AOT compiled? My abstract class, maybe too abstract? Not sure.
public abstract class SqlRepositoryLite<T, TInterface> : IRepositoryLite<TInterface> where T : class, IDto, TInterface, new()
{
public IEnumerable<TInterface> Items => Connection.Table<T>();
Crash reports:
SIGABRT: Attempting to JIT compile method '(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_CharacterItem_int (PFAssistant.Core.Services.CharacterItem,int)' while running in aot-only mode. See https://learn.microsoft.com/xamarin/ios/internals/limitations for more information.
Stacktrace:
FastColumnSetter+<>c__DisplayClass2_0`2[ObjectType,ColumnMemberType].<CreateTypedSetterDelegate>b__0 (System.Object o, SQLitePCL.sqlite3_stmt stmt, System.Int32 i)
SQLiteCommand+<ExecuteDeferredQuery>d__12`1[T].MoveNext ()
List`1[T].AddEnumerable (System.Collections.Generic.IEnumerable`1[T] enumerable)
System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) <0x1052cce30 + 0x0021f> in <25bf495f7d6b4944aa395b3ab5293479#0dcf7231fb8229d159bd9a1419156fe3>:0
Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source)
SQLiteCommand.ExecuteQuery[T] ()
Update: Would seem updating Sqlite-net-pcl to v1.8.116 was a major part of my issue, had issues with 1.6.292 as well. 1.7.335 worked perfectly.
I found the same to be the case today. Downgrading to 1.7.335 is the solution.

The type initializer for 'Android.Runtime.UncaughtExceptionHandler' threw an exception

my xamarin android app, which was working fine, started to crash on each launch with this exception.
The app is built from appcenter's build service, as it always has. If i build it locally in Debug or Release mode, it launches fine. Using a device with Android 7.
Did anyone encountered this exception and knows what to do ?
Ty !
18828 W monodroid: Calling into managed runtime init
E mono :
E mono : Unhandled Exception:
E mono : System.TypeInitializationException: The type initializer for 'Android.Runtime.UncaughtExceptionHandler' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
E mono : Parameter name: method
E mono : at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) <0x56d026b4 + 0x00d74> in :0
E mono : at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) <0x56d03594 + 0x0001f> in :0
: at Android.Runtime.UncaughtExceptionHandler..cctor () <0x57d908a4 + 0x0003f> in :0
: --- End of inner exception stack trace ---
: at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
: at Android.Runtime.JNIEnv.Initialize (Android.Runtime.JnienvInitializeArgs* args)
-- EDIT
All AOT/LVVM/Concurrent garbage collector/proguard/multidex options are enabled
-- EDIT 2
Source code of error: https://github.com/xamarin/xamarin-android/blob/master/src/Mono.Android/Android.Runtime/UncaughtExceptionHandler.cs
static UncaughtExceptionHandler ()
{
var mono_UnhandledException = typeof (System.Diagnostics.Debugger)
.GetMethod ("Mono_UnhandledException", BindingFlags.NonPublic | BindingFlags.Static);
mono_unhandled_exception = (Action<Exception>) Delegate.CreateDelegate (typeof(Action<Exception>), mono_UnhandledException);
var ad_due = typeof (AppDomain)
.GetMethod ("DoUnhandledException",
bindingAttr: BindingFlags.NonPublic | BindingFlags.Instance,
binder: null,
types: new []{typeof (UnhandledExceptionEventArgs)},
modifiers: null);
if (ad_due != null) {
AppDomain_DoUnhandledException = (Action<AppDomain, UnhandledExceptionEventArgs>) Delegate.CreateDelegate (
typeof (Action<AppDomain, UnhandledExceptionEventArgs>), ad_due);
}
}
So it seems either mono_UnhandledException is null or AppDomain_DoUnhandledException is null.
Will try to upgrade or downgrade mono version in appcenter. It should be wrong.
-- EDIT 3
AppDomain.cs has changed recently in mono:
https://github.com/mono/mono/commits/c1cbe060f617707258fd5111fd5ffd7ccd581899/mcs/class/corlib/System/AppDomain.cs
But DoUnhandledException has not changed.
-- EDIT 4
Works fine when built/published locally. So the problem is specific to appcenter.
AppCenter has recently released Mono 5.8 bundled with Xamarin.Android 8.2 (which supports TargetFrameworkVersion: 8.1), in order to use it, please change your branch configuration -> Save&Build.
Also filed the issue for investigation by Xamarin.Android team.
In my case, the issue was caused by using Android SDK 8.1 which App Center doesn't support yet.
I had to downgrade to SDK 8.0 and now build works fine.
App Center team promised to add support to SDK 8.1, but they don't have an ETA yet.
we faced the same issue with jenkins and msbuild. rollback to 8.0 as target and disable 'use latest' works. locally, with 'use latest', build tools 26.0.3 and msbuild on macos app works like a charm. not sure what build tools installed on jenkins.
I'm having the same issue in App Center. My Android app is set to target android 8.1 (latest) and builds ok in App Center but when running "launch test" it fails.
The app is running fine locally in Debug and Release modes.
I tried disabling launch test so the app can be distributed to my collaborators. When any of my collabortors download the app and use it, the app doesn't work.
I built it using VSTS and distributed through App Center to my collaborators and they said the app is working, so I can conclude it's an App Center build issue.
I didn't try to build my app using Android 8.0 because some nuget packages only work on Android 8.1 and I didn't have time to downgrade them.

UnityEditor.BuildPlayerWindow+BuildMethodException: when building Unity project for iOS

I am using Unity 2017.1.Op4 and I keep getting the following error when building the project for iOS:
UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors.
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x001b9] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:162
at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00050] in /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:83
UnityEditor.HostView:OnGUI()
The build folder is also empty.
After making a Google search, a few recommended that I change the Product Name in the Player Settings.
Another workaround suggested: Clearing all errors and switching inspector to show Camera's components (it doesn't matter as long as it is not Player Settings window).
Both suggestions didn't work. How can I resolve this issue?
I just had this problem and solved. I hope this helps the next person with this problem.
My code contained wrong code like here:
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
Correct Code Hear
#elif UNITY_ANDROID || UNITY_IPHONE
Compiled Error Code Hear
#else
#endif

System.AggregateException: One or more errors occured ---> MonoTouch.Design.Client.DesignerRemoteException

I have been working in storyboard designing app for IOS. No code, besides automatically generated one is written. After reopening storyboard file in Xamarin I got following error:
System.AggregateException: One or more errors occured ---> MonoTouch.Design.Client.DesignerRemoteException: System.ArgumentNullException: Argument cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2[MonoTouch.UIKit.UIImage,System.String].set_Item (MonoTouch.UIKit.UIImage key, System.String value) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:216
at MonoTouch.Design.Server.ImageResourceManager.SetImage (System.String name, MonoTouch.UIKit.UIImage value) in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Server/ImageResourceManager.cs:79
at MonoTouch.Design.Server.SessionController+<PostImageResource>c__AnonStorey3.<>m__0 () in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Server/SessionController.cs:167
at MonoTouch.Design.NativeExtensions+<SafeInvokeOnMainThread>c__AnonStorey0.<>m__0 () in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Server/Util/NativeExtensions.cs:378
at MonoTouch.Design.Client.ServerProcessConnection.SendRequest (MonoTouch.Design.CommandRequest req, Boolean throwIfNotRunning) [0x0007f] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:195
at MonoTouch.Design.Client.ServerProcessConnection.SendRequest[Object] (MonoTouch.Design.CommandRequest req, Boolean throwIfNotRunning) [0x00004] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:202
at MonoTouch.Design.Client.ServerProcessConnection.PostResources (MonoTouch.Design.DesignSession session, MonoTouch.Design.ImageResource[] resources) [0x0003f] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:132
at MonoTouch.Design.Client.IPhoneDesignerSession+<SendImageResources>c__AnonStorey13.<>m__1 () [0x00019] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/IPhoneDesignerSession.cs:1329
at System.Threading.Tasks.TaskActionInvoker+FuncInvoke`1[System.Object].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in /Volumes/build-root-ramdisk/mono-3.6.0/mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs:242
at System.Threading.Tasks.Task.InnerInvoke () [0x00031] in /Volumes/build-root-ramdisk/mono-3.6.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:548
at System.Threading.Tasks.Task.ThreadStart () [0x000d0] in /Volumes/build-root-ramdisk/mono-3.6.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:438
Can anybody help to figure out what this means?
As far as I can tell the error is caused by the following:
iOS Designer opens the StoryBoard and tries to parse the XML inside.
Upon parsing it calls MonoTouch.Design.Server (which probably runs code against Xcode for rendering the XML). While doing so it encounters a ViewElement containing a UIImage. So then it tries to setup the UIImage using parameters stored in a Dictionary (filled using the same XML). When it tries to access that Dictionary for the parameters to yield to UIImage it puts in a 'null' for the key and this causes your error.
Now I don't know exactly what in your Storyboard causes this error as you haven't provided the Storyboard-file in question (nor can I guarantee I could find that error if you had), but you can try some of the following things to try and resolve the issue.
Try and open the Storyboard in Xcode instead of iOS Designer. It sometimes manages to fix corrupt Storyboards that iOS Designer can't handle.
Open the Storyboard in XML-view and have a look at the elements that have UIImages in them. Try and see if anyone of them has a 'strange' name, source, value or something.
Post the Storyboard here and see if anyone else can spot the error
I encountered a similar scenario in that the error message started exactly as in the original post. I could not open the storyboard both in Visual Studio 2015 and in Xamarin Studio 5.10.3 (build 51)
After spending some time in comparing the changes to the .csproj file i figured out that the image for ipad caused this issue for me. I do not know the actual reason for the original post but for me, i had an image to be used as the app logo for ipad and i had named it as "imagename#ipad.png". It turns out this freaks out the designer even though XCode 7 perfectly opens the storyboard.
Finally i renamed the image as "imagename~iPad.png" and that did the trick. Both VS 2015 and XS 5.10.3 are happy to open the storyboard!
Documentation from Xamarin below for working with images
https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/sizes-and-filenames/

Using SQLCipher with MonoTouch

I've compiled a static library and linked both SQLCipher and OpenSSL. The full project, makefile, and compiled library can be found here:
https://github.com/anujb/SQLCipherNet
When I link the resulting library in a normal Objective-C Xcode project, the call to sqlite3_key works fine.
I've linked the same library into a MonoTouch project using:
-gcc_flags "-L${ProjectDir} -lsqlciphernet -force_load ${ProjectDir}/libsqlciphernet.a"
Then I've modified SQLite-NET to call the the key function, after every SQLite3.Open(...) function:
[DllImport("__Internal", EntryPoint = "sqlite3_key")]
public static extern Result Key(IntPtr db, string key, int keyLength);
But I get a EntryPointNotFoundException when the Key method is called. Here's the stack trace:
System.EntryPointNotFoundException has been thrown at:
at (wrapper managed-to-native) SQLite.SQLite3:Decrypt (intptr,string,int)
at SQLite.SQLiteConnection..ctor (System.String databasePath) [0x00031] in
../SQLite.cs:108
Obviously the stacktrace isn't particularly helpful, but I'm at a loss as to where to begin to debug this issue. Halp?
I get the same error when building your solution for "Debug|iPhoneSimulator". However your project options, for this configuration, do not include the gcc_flags you mentioned - so the exception is totally normal.
Trying to build the "Debug|iPhone" configuration (where the options are specified) fails because of path issues... but I'm pretty sure it would work if I fixed them ;-)
UPDATE
Moving the library to it's right location gives me:
Undefined symbols for architecture armv6: "___udivmodsi4",
referenced from:
_sqlite3BitvecSet in libsqlciphernet.a(sqlite3.o)
_sqlite3BitvecClear in libsqlciphernet.a(sqlite3.o)
_sqlite3BitvecTest in libsqlciphernet.a(sqlite3.o) ld: symbol(s) not found for architecture armv6
I believe it's missing because of libopenssl ?

Resources