I have a 5+ year old Xamarin app using version 3.2 Beta 2 (was using 3.1.7 with same results).
The app works fine on iOS and Android (with API target set to 33 or running android with API 33 or lower).
I need to update the Target API to 34 for Google play requirements and the sync works fine on Android devices with OS < 34 but on 34 it cannot connect to the
sync gateway. The connection times out. The app eventually crashes with an exception “Java.Lang.SecurityException: com.mytestApp.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn’t being registered exclusively for system broadcasts”
Logs
2024-07-09 11:51:04.0214|DEBUG|SyncService.cs|***** Setup Sync for URL: https://syncdev.mysyncdomain.com/sync_gateway
[CouchbaseLite] [1]| [Database] (Startup) [1] CouchbaseLite/3.2.0 (.NET; Android 14 [API 34]; Google sdk_gphone64_x86_64) Build/105 LiteCore/3.2.0 (159) Commit/ba1d8f7f
[CouchbaseLite] [1]| [Database] (Logging) [1] Database.Log.File.Config is null, meaning file logging is disabled. Log files required for product support are not being generated.
[CouchbaseLite] [1]| [Database] (Database) [1] Opening database at /data/user/0/com.mytestApp.app/files/data.cblite2
[CouchbaseLite] [1]| [Database] {Shared#1}==> N8litecore8DataFile6SharedE 0x7b411f9f01c8 @0x7b411f9f01c8
[CouchbaseLite] [1]| [Database] Obj=/Shared#1/ Path=/data/data/com.mytestApp.app/files/data.cblite2/db.sqlite3 Instantiated
[CouchbaseLite] [1]| [Database] {DB#2}==> N8litecore14SQLiteDataFileE /data/user/0/com.mytestApp.app/files/data.cblite2/db.sqlite3 @0x7b420fa2f810
[CouchbaseLite] [1]| [Database] Obj=/DB#2/ File=Shared#1 Opening database
[CouchbaseLite] [1]| [Database] {Collection#3}==> N8litecore14CollectionImplE data/_default @0x7b418fa19af0
[CouchbaseLite] [1]| [Database] Obj=/Collection#3/ DB=DB#2 Instantiated
[CouchbaseLite] [1]| [Database] Obj=/DB#2/ Next expiration time is 0
[CouchbaseLite] [1]| [Database] Obj=/DB#2/ Next expiration time is 0
[CouchbaseLite] [1]| [Replicator] (Database) [1] There is no saved HTTP cookies.
[CouchbaseLite] [1]| [Replicator] (Replicator) [1] Replicator[<*> wss://syncdev.mysyncdomain.com/sync_gateway]: Starting
[CouchbaseLite] [1]| [Database] {DB#4}==> N8litecore14SQLiteDataFileE /data/user/0/com.mytestApp.app/files/data.cblite2/db.sqlite3 @0x7b420fa307d0
[CouchbaseLite] [1]| [Database] Obj=/DB#4/ File=Shared#1 Opening database
[CouchbaseLite] [1]| [Database] {Collection#5}==> N8litecore14CollectionImplE data/_default @0x7b418fa187b0
[CouchbaseLite] [1]| [Database] Obj=/Collection#5/ DB=DB#4 Instantiated
[CouchbaseLite] [1]| [Database] Obj=/DB#4/ Next expiration time is 0
[CouchbaseLite] [1]| [Database] Obj=/DB#4/ Next expiration time is 0
[CouchbaseLite] [1]| [Network] {N8litecore4blip10ConnectionE#6}==> N8litecore4blip10ConnectionE ->wss://syncdev.mysyncdomain.com:443/sync_gateway/_blipsync @0x7b41afa9c360
[CouchbaseLite] [1]| [Network] Obj=/N8litecore4blip10ConnectionE#6/ Opening connection...
[CouchbaseLite] [1]| [Replicator] Starting Scheduler<0x7b422fa531f0> with 4 threads
[CouchbaseLite] [1]| [Network] {BLIPIO#7}==> N8litecore4blip6BLIPIOE ->wss://syncdev.mysyncdomain.com:443/sync_gateway/_blipsync @0x7b415fb3cfb0
[CouchbaseLite] [1]| [Network] {N8litecore4repl12C4SocketImplE#8}==> N8litecore4repl12C4SocketImplE wss://syncdev.mysyncdomain.com:443/sync_gateway/_blipsync @0x7b405faed778
[CouchbaseLite] [1]| [Replicator] {Repl#9}==> N8litecore4repl10ReplicatorE ->wss://syncdev.mysyncdomain.com:443/sync_gateway/_blipsync @0x7b415fb3ad30
[CouchbaseLite] [1]| [Replicator] {N8litecore4repl8DBAccessE#10}==> N8litecore4repl8DBAccessE 0x7b41dfa32210 @0x7b41dfa32210
[CouchbaseLite] [1]| [Replicator] Obj=/Repl#9/ {Coll#-1} DB=DB#4 Instantiated {{Coll#0} "_default": {"Push": continuous, "Pull": continuous, Options={autoPurge:true, headers:{User-Agent:"CouchbaseLite/3.2.0 (.NET; Android 14 [API 34]; Google sdk_gphone64_x86_64) Build/105 LiteCore/3.2.0 (159) Commit/ba1d8f7f"}}}}
[CouchbaseLite] Options={auth:{password:"********", type:"Basic", username:"REMOVED"}, autoPurge:true, headers:{User-Agent:"CouchbaseLite/3.2.0 (.NET; Android 14 [API 34]; Google sdk_gphone64_x86_64) Build/105 LiteCore/3.2.0 (159) Commit/ba1d8f7f"}, maxRetries:2147483646}
[CouchbaseLite] [1]| [Replicator] {N8litecore4repl6PusherE#11}==> N8litecore4repl6PusherE Repl#9 @0x7b41dfa29ec0
[CouchbaseLite] [1]| [Replicator] {N8litecore4repl8InserterE#12}==> N8litecore4repl8InserterE Repl#9 @0x7b41dfa26fe0
[CouchbaseLite] [1]| [Replicator] {N8litecore4repl9RevFinderE#13}==> N8litecore4repl9RevFinderE Repl#9 @0x7b405fae73e0
[CouchbaseLite] [1]| [Replicator] {N8litecore4repl6PullerE#14}==> N8litecore4repl6PullerE Repl#9 @0x7b415fb38210
[CouchbaseLite] [1]| [Replicator] Obj=/Repl#9/ {Coll#-1} Remote-DB ID 1 found for target <wss://syncdev.mysyncdomain.com:443/sync_gateway/_blipsync>
[CouchbaseLite] [1]| [Replicator] {DNRepl@A3/C4Repl#15}==> N8litecore18C4RemoteReplicatorE 0x7b420fa31960 @0x7b420fa31960
[CouchbaseLite] [1]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/ C4RemoteRepl 0x7b420fa31960 created Repl 0x7b415fb3ad30
[CouchbaseLite] [1]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/ Starting Replicator Repl#9 with config: {{{Coll#0} "_default": {"Push": continuous, "Pull": continuous, Options={autoPurge:true, headers:{User-Agent:"CouchbaseLite/3.2.0 (.NET; Android 14 [API 34]; Google sdk_gphone64_x86_64) Build/105 LiteCore/3.2.0 (159) Commit/ba1d8f7f"}}}}
[CouchbaseLite] Options={auth:{password:"********", type:"Basic", username:"REMOVED"}, autoPurge:true, headers:{User-Agent:"CouchbaseLite/3.2.0 (.NET; Android 14 [API 34]; Google sdk_gphone64_x86_64) Build/105 LiteCore/3.2.0 (159) Commit/ba1d8f7f"}, maxRetries:2147483646}}
[CouchbaseLite] [10]| [Query] RecordEnumerator 0x7b41ef9e8358: (default, 110 0)
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#0} Scanning for pre-existing conflicts...
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#0} Found 0 conflicted docs in 0.013 sec
[CouchbaseLite] [1]| [Replicator] (Replicator) [1] Replicator[<*> wss://syncdev.mysyncdomain.com/sync_gateway] is Connecting, progress 0/0
[CouchbaseLite] [1]| [Replicator] (Replicator) [1] Replicator[<*> wss://syncdev.mysyncdomain.com/sync_gateway] is Connecting, progress 0/0
[CouchbaseLite] [11]| [Network] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4blip10ConnectionE#6/N8litecore4repl12C4SocketImplE#8/ Connecting...
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#0} No local checkpoint 'cp-QET1sZrm7T0dhR275cwib+HAtgA='
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} activityLevel=connecting: connectionState=1, savingChkpt=0
2024-07-09 11:51:04.2058|TRACE|SyncService.cs|***** Replication Status Change. DB:[Data], Activity:[Connecting], Progress:0 of 0
[CouchbaseLite] [Thread Pool Worker]| [Replicator] (WebSocketWrapper) [Thread Pool Worker (7)] c4Socket is retained, and reachability status monitor is starting.
[CouchbaseLite] [13]| [Network] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4blip10ConnectionE#6/N8litecore4repl12C4SocketImplE#8/ No response received after 15 sec -- disconnecting
[CouchbaseLite] [13]| [Network] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4blip10ConnectionE#6/N8litecore4repl12C4SocketImplE#8/ Calling closeSocket before the socket is connected
[CouchbaseLite] [Thread Pool Worker]| [Replicator] (WebSocketWrapper) [Thread Pool Worker (5)] Closing socket normally due to request from LiteCore
[CouchbaseLite] [Thread Pool Worker]| [Network] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4blip10ConnectionE#6/N8litecore4repl12C4SocketImplE#8/ WebSocket failed to connect! (reason=Network error 3)
[CouchbaseLite] [14]| [Network] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4blip10ConnectionE#6/ Closed with Network error 3:
[CouchbaseLite] [14]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} Connection closed with Network error 3: "" (state=1->-1)
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4repl6PusherE#11/ {Coll#0} activityLevel=stopped: pendingResponseCount=0, caughtUp=0, changeLists=0, revsInFlight=0, blobsInFlight=0, awaitingReply=0, revsToSend=0, pushingDocs=0, pendingSequences=0
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4repl6PusherE#11/ {Coll#0} now stopped
[CouchbaseLite] [Thread Pool Worker]| [Replicator] (WebSocketWrapper) [Thread Pool Worker (5)] c4Socket is closed and released, reachability is stopping monitor.
[CouchbaseLite] [Thread Pool Worker]| [Replicator] (WebSocketWrapper) [Thread Pool Worker (8)] Reset Connections completed..
[CouchbaseLite] [14]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ Got LiteCore error: Network error 3, "connection timed out"
[CouchbaseLite] [14]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} (collection: 4294967295) progress +0/+0, 0 docs -- now 0 / 0, 0 docs
[CouchbaseLite] [14]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} activityLevel=connecting: connectionState=-1, savingChkpt=0
[CouchbaseLite] [14]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/ State: connecting, progress=0.00%, error=Network error 3, "connection timed out"
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} pushStatus=stopped, pullStatus=busy, progress=0/0/0
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} Replicator status collection-wise: pushStatus=stopped, pullStatus=busy, progress=0/0, docCount=0
[CouchbaseLite] [10]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} activityLevel=connecting: connectionState=-1, savingChkpt=0
Thread started: #13
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4repl6PullerE#14/ {Coll#0} activityLevel=stopped: pendingResponseCount=0, _caughtUp=0, _pendingRevMessages=0, _activeIncomingRevs=0, _waitingRevMessages=0, _unfinishedIncomingRevs=0
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/N8litecore4repl6PullerE#14/ {Coll#0} now stopped
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} pushStatus=stopped, pullStatus=stopped, progress=0/0/0
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} Replicator status collection-wise: pushStatus=stopped, pullStatus=stopped, progress=0/0, docCount=0
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} activityLevel=stopped: connectionState=-1, savingChkpt=0
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/Repl#9/ {Coll#-1} now stopped
[CouchbaseLite] [15]| [Database] Obj=/DB#4/ Housekeeping: 0 of 17 pages free (0%)
[CouchbaseLite] [15]| [Database] Obj=/DB#4/ Closed SQLite database
[CouchbaseLite] [15]| [Database] Obj=/DB#4/ Closing database
[CouchbaseLite] [15]| [Database] Obj=/Collection#5/ Closing
[CouchbaseLite] [15]| [Database] Obj=/Collection#5/ Closed
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/ Transient error (Network error 3, "connection timed out"); attempt #2 in 2 sec...
[CouchbaseLite] [15]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/ State: offline, progress=0.00%, error=Network error 3, "connection timed out"
[CouchbaseLite] [15]| [Replicator] (Replicator) [15] Replicator[<*> wss://syncdev.mysyncdomain.com/sync_gateway] is Offline, progress 0/0
[CouchbaseLite] [13]| [Replicator] Obj=/DNRepl@A3/C4Repl#15/ Retrying connection to wss://syncdev.mysyncdomain.com:443/sync_gateway/_blipsync (attempt #2)...
[CouchbaseLite] [13]| [Database] {DB#16}==> N8litecore14SQLiteDataFileE /data/user/0/com.mytestApp.app/files/data.cblite2/db.sqlite3 @0x7b420fa44b90
[CouchbaseLite] [13]| [Database] Obj=/DB#16/ File=Shared#1 Opening database
System.UnhandledExceptionEventArgs
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.SecurityException: com.mytestApp.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts ---> Android.OS.RemoteException: Remote stack trace:
[mono-rt] at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13908)
[mono-rt] at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
[mono-rt] at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
[mono-rt] at android.os.Binder.execTransactInternal(Binder.java:1339)
[mono-rt] at android.os.Binder.execTransact(Binder.java:1275)
[mono-rt]
[mono-rt] --- End of inner exception stack trace ---
[mono-rt] at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00068] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/JniEnvironment.g.cs:11524
[mono-rt] at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00036] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:867
[mono-rt] at Android.Content.ContextWrapper.RegisterReceiver (Android.Content.BroadcastReceiver receiver, Android.Content.IntentFilter filter) [0x00049] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-31/mcw/Android.Content.ContextWrapper.cs:2464
[mono-rt] at Xamarin.Essentials.Connectivity.StartListeners () [0x00045] in D:\a\_work\1\s\Xamarin.Essentials\Connectivity\Connectivity.android.cs:37
[mono-rt] at Xamarin.Essentials.Connectivity.add_ConnectivityChanged (System.EventHandler`1[TEventArgs] value) [0x0001c] in D:\a\_work\1\s\Xamarin.Essentials\Connectivity\Connectivity.shared.cs:31
[mono-rt] at Couchbase.Lite.Support.XEReachability.Start () [0x00000] in /_/src/Couchbase.Lite.Shared/Support/Android/XEReachability.cs:55
[mono-rt] at Couchbase.Lite.Sync.Replicator.StartReachabilityObserver () [0x00067] in /_/src/Couchbase.Lite.Shared/API/Sync/Replicator.cs:772
[mono-rt] at Couchbase.Lite.Sync.Replicator.StatusChangedCallback (LiteCore.Interop.C4ReplicatorStatus status) [0x00051] in /_/src/Couchbase.Lite.Shared/API/Sync/Replicator.cs:727
[mono-rt] at Couchbase.Lite.Sync.Replicator+<>c__DisplayClass52_0.<StatusChangedCallback>b__0 () [0x00000] in /_/src/Couchbase.Lite.Shared/API/Sync/Replicator.cs:701
[mono-rt] at Dispatch.SerialQueue.DispatchSync (System.Action action) [0x0007f] in <8cc169afb4db489dab425f15c162dc79>:0
[mono-rt] at Couchbase.Lite.Sync.Replicator.StatusChangedCallback (LiteCore.Interop.C4Replicator* repl, LiteCore.Interop.C4ReplicatorStatus status, System.Void* context) [0x00045] in /_/src/Couchbase.Lite.Shared/API/Sync/Replicator.cs:699
[mono-rt] at (wrapper native-to-managed) Couchbase.Lite.Sync.Replicator.StatusChangedCallback(LiteCore.Interop.C4Replicator*,LiteCore.Interop.C4ReplicatorStatus,void*)
[mono-rt] --- End of managed Java.Lang.SecurityException stack trace ---
[mono-rt] java.lang.SecurityException: com.mytestApp.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
[mono-rt] at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
[mono-rt] at android.os.Parcel.createException(Parcel.java:3041)
[mono-rt] at android.os.Parcel.readException(Parcel.java:3024)
[mono-rt] at android.os.Parcel.readException(Parcel.java:2966)
[mono-rt] at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684)
[mono-rt] at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852)
[mono-rt] at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
[mono-rt] at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)
[mono-rt] at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
[mono-rt] Caused by: android.os.RemoteException: Remote stack trace:
[mono-rt] at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13908)
[mono-rt] at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
[mono-rt] at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
[mono-rt] at android.os.Binder.execTransactInternal(Binder.java:1339)
[mono-rt] at android.os.Binder.execTransact(Binder.java:1275)
[mono-rt]
[mono-rt]
[CouchbaseLite] [13]| [Database] {Collection#17}==> N8litecore14CollectionImplE data/_default @0x7b418fa1b0f0
[CouchbaseLite] [13]| [Database] Obj=/Collection#17/ DB=DB#16 Instantiated
[CouchbaseLite] [13]| [Database] Obj=/DB#16/ Next expiration time is 0
[CouchbaseLite] [13]| [Database] Obj=/DB#16/ Next expiration time is 0
[libc] FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b3fbe47a6ac)
[libc] Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x148 in tid 11102 (Thread-13), pid 10957 (tyinspectionapp)
[libc] FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b42dab5f9e8)
This looks like it could be solved by upgrading Xamarin Essentials to its final 1.8.1 release.
1 Like
Thanks for your quick reply. This resolved the issue.