snowplow / snowplow-unity-tracker

Snowplow event tracker for Unity. Add analytics to your Unity games and apps
http://snowplowanalytics.com
Apache License 2.0
16 stars 11 forks source link

SQLite error on Android #12

Closed kayalardanmehmet closed 5 years ago

kayalardanmehmet commented 5 years ago

When I try to create new tracker I get this error on Android devices:

Unity: SqliteSyntaxException: unable to open database file
      at Mono.Data.SqliteClient.SqliteCommand.GetNextStatement (System.IntPtr pzStart, System.IntPtr& pzTail, System.IntPtr& pStmt) [0x00037] in <498eeeae5bb444ae9b2470f507540407>:0 
      at Mono.Data.SqliteClient.SqliteCommand.ExecuteReader (System.Data.CommandBehavior behavior, System.Boolean want_results, System.Int32& rows_affected) [0x00059] in <498eeeae5bb444ae9b2470f507540407>:0 
      at Mono.Data.SqliteClient.SqliteCommand.ExecuteNonQuery () [0x00000] in <498eeeae5bb444ae9b2470f507540407>:0 
      at SnowplowTracker.Storage.EventStore.Open () [0x0004f] in <ad054742dbf74950a262afdb59767de3>:0 
      at SnowplowTracker.Storage.EventStore..ctor () [0x00008] in <ad054742dbf74950a262afdb59767de3>:0 
      at SnowplowTracker.Emitters.AsyncEmitter..ctor (System.String endpoint, SnowplowTracker.Enums.HttpProtocol protocol, SnowplowTracker.Enums.HttpMethod method, System.Int32 sendLimit, System.Int64 byteLimitGet, System.Int64 byteLimitPost) [0x00080] in <ad054742dbf74950a262afdb

Also, when I import your plugin it also copies System.Data.dll and System.Web.dll. This time Visual Compiler returns this error:

error CS1703: Multiple assemblies with equivalent identity have been imported: '/Users/mehmetkaya/Desktop/apps/Hexart/hexart/Assets/Plugins/System.Data.dll' and '/Applications/Unity/Unity.app/Contents/MonoBleedingEdge/lib/mono/4.7.1-api/System.Data.dll'. Remove one of the duplicate references.

When I remove them from the Plugins it can be build. Could this be the problem ?

BenFradet commented 5 years ago

hey @kayalardanmehmet , thanks for the report, if you use the one you built locally, does creating the tracker work?

kayalardanmehmet commented 5 years ago

hello @BenFradet, thanks for your quick reply. I am not sure that I understood correctly (I am not good at C# and Unity, I am just trying to implement snowplow tracker for an existing project) but, when I run(play) the application on the Unity it works. It sends events to collector successfully. But when I build it for Android or iOS it doesn't work. I also tried it on an iPhone. Here, you can see the logs from device:

2019-03-07 14:50:03.496490+0300 hexart[678:152689] [logging-persist] cannot open file at line 42263 of [95fbac39ba]
2019-03-07 14:50:03.496520+0300 hexart[678:152689] [logging-persist] os_unix.c:42263: (0) open(//snowplow_events.db) - Undefined error: 0
2019-03-07 14:50:03.498493+0300 hexart[678:152689] [logging] API call with unopened database connection pointer
2019-03-07 14:50:03.498521+0300 hexart[678:152689] [logging] misuse at line 127904 of [95fbac39ba]
BenFradet commented 5 years ago

When you said:

When I remove them from the Plugins it can be build

Did it apply to both unity and mobile or just mobile?

kayalardanmehmet commented 5 years ago

I found the problem. We need to use full path of application on Android and iOS to create or open db file. By default, DATABASE_NAME in tracker is defined as "URI=file:snowplow_events.db". When I change it to "URI=file:"+Application.persistentDataPath+"/snowplow_events.db" it starts working on Android and iOS too. I can see that you added a parameter to set custom DATABASE_NAME but I made a change for the default value and will make a pull request about it.