Every time add firebase dependencies, run my app and socket connect to endpoint, my app crashes immediately.
I'm using firebase and socket.io together and is causing the crash due to compatibility issues. Can firebase and socket.io be used together?
I get the following error when i added firebase and try to connect to socket.io in my project
E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.project.hubrydemanagerapp, PID: 30101
java.lang.NoSuchMethodError: No virtual method callEngineGetConnection(Lcom/squareup/okhttp/Call;)Lcom/squareup/okhttp/Connection; in class Lcom/squareup/okhttp/internal/Internal; or its super classes (declaration of 'com.squareup.okhttp.internal.Internal' appears in /data/app/com.project.hubrydemanagerapp-t3ZbPD-QZAE9y2BMT64Cdg==/base.apk!classes3.dex)
at com.squareup.okhttp.ws.WebSocketCall.createWebSocket(WebSocketCall.java:154)
at com.squareup.okhttp.ws.WebSocketCall.access$000(WebSocketCall.java:42)
at com.squareup.okhttp.ws.WebSocketCall$1.onResponse(WebSocketCall.java:102)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
My dependencies:
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-firestore:21.3.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation('com.github.nkzawa:socket.io-client:0.6.0') {
exclude group: 'org.json', module: 'json'
}
Endpoint
"https://hubryde-trip-service.herokuapp.com/";
"https://hubryde-request-service.herokuapp.com/";
Connection. I'm using Application class to create socket model.
tripSocket = IO.socket(TRIP_URL);
socket2 = IO.socket(BUS_URL);
SocketEndpoint app = (SocketEndpoint) getApplication();
tripSocket = app.getmTripSocket();
if(!tripSocket.connected()) {
tripSocket.connect();
}
socket2 = app.getmBusLocationSocket();
if(!socket2.connected()) {
socket2.connect();
}
}
Im also Using com.github.nkzawa:socket.io-client:0.6.0.
That crash also happened to me after adding firebase in app messaging module,
for me the quick fix (until this will be fixed, hopefully soon..)
was to add exclude..
hope it helps..
implementation ('com.google.firebase:firebase-inappmessaging-display:19.0.3') {
exclude group: 'com.squareup.okhttp', module: 'okhttp'
}
my full gradle file: (Using AndroidX)
implementation 'com.github.nkzawa:socket.io-client:0.6.0'
implementation 'tech.gusavila92:java-android-websocket-client:1.2.2'
implementation "com.google.firebase:firebase-messaging:20.1.4"
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation ('com.google.firebase:firebase-inappmessaging-display:19.0.3') {
exclude group: 'com.squareup.okhttp', module: 'okhttp'
}
I have tested your dependencies and i realized firestore dependency is the reason for the crash not the entire firebase dependencies. It seems not to support The type of socket.io you are using OR not even support socket.io at all.
I even went further to test older version of cloud firestore, but no luck - The app keeps crashing with the same error.
So remove firestore and sync your project if you will see the error.
Related
I just found out that my Google Play Services are adding into merged manifest AD permission and for that reason I cant upload app to my playstore because it requires reasoning why I want ads in my app (I don't).
These are my gradle libraries:
//Google SDK
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-auth:20.3.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.0.3'
//GCM for internet connection monitoring
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
//GooglePay
implementation 'com.google.android.gms:play-services-wallet:19.1.0'
//Google Firebase SDK - Crashlytics, Firebase Messaging
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation ('com.google.firebase:firebase-crashlytics:18.2.13') {
transitive = true
}
implementation 'com.google.firebase:firebase-messaging:23.0.8'
This is merged manifest:
It seems like its google analytics (firebase). But I don't want and don't use any ad content in my app so I don't understand why is Google adding this stuff into my app without my approval.
I just tried to do this:
implementation 'com.google.firebase:firebase-core:21.1.1' {
exclude module: "play-services-ads-identifier"
exclude module: "play-services-measurement"
exclude module: "play-services-measurement-sdk"
}
as I found out but its not even compiling (got GradleScriptException):
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method com.google.firebase:firebase-core:21.1.1() for arguments [build_ballt3q1t2mmz35mzah3ugy17$_run_closure2$_closure23#69dcec81] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
In our app, this issue has 286454 ANR events affecting 182342 users just in last 90 days.
It's mostly happening in Android 12 (%99).
I couldn't find out why this causes ANR yet
We are using GsonConverter like this:
Retrofit
.Builder().
...
.addConverterFactory(GsonConverterFactory.create())
And here is our retrofit and ohttp3 implemetations
// Retrofit & Okhttp3
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
implementation('com.squareup.okhttp3:okhttp-urlconnection:4.9.1') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation('com.squareup.retrofit2:retrofit:2.9.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
I've opened a issue about this too.
https://github.com/square/retrofit/issues/3765
Can someone help me with this issue?
Crashlytics Dashboard of this issue
Event Summary - 1
Event Summary - 2
I'm trying to use azure chat and calling in the same application. Right now I'm getting an error
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/microsoft/trouterclient/registration/ISkypetokenProvider;
at com.azure.android.communication.chat.ChatAsyncClient.<init>(ChatAsyncClient.java:50)
at com.azure.android.communication.chat.ChatClientBuilder.buildAsyncClient(ChatClientBuilder.java:233)
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started the QuickStart library suggested I exclude files from dependency like below and this is causing the issue I'm seeing.
implementation 'com.azure.android:azure-communication-calling:2.0.0'
implementation 'com.azure.android:azure-communication-common:1.0.1'
implementation 'org.slf4j:slf4j-log4j12:1.7.29'
implementation ("com.azure.android:azure-communication-chat:1.1.0-beta.4") {
exclude group: 'com.microsoft', module: 'trouter-client-android'
}
If I try to remove this though I will receive this error
Duplicate class com.skype.rt.WiFiNetworkState found in modules jetified-azure-communication-calling-2.0.0-runtime (com.azure.android:azure-communication-calling:2.0.0) and jetified-trouter-client-android-0.1.1-runtime (com.microsoft:trouter-client-android:0.1.1)
Am I using the wrong versions or is there a different solution to this?
Chat for azure can't work with the real time notification functionality in android as of that version.
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started?tabs=windows&pivots=programming-language-android#receive-chat-messages-from-a-chat-thread
All related posts seem to indicate a version mismatch between Firebase and Playservices, but I didn't find one wrt. Firestore. I tried all kinds of permutations, but didn't find a fix. Here is my gradle:
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
//----------------------------------------------------------------------------------------------
//--- FireBase
//----------------------------------------------------------------------------------------------
// Firebase DataBase
// implementation 'com.google.firebase:firebase-database:18.0.0'
// implementation 'com.google.firebase:firebase-auth:18.0.0'
// Firebase Firestore
// Need to exclude 'guava' to avoid dreaded 'Duplicate class' Errors during compile
implementation ('com.google.firebase:firebase-firestore:20.1.0')
{
exclude group: 'com.google.guava'
}
//----------------------------------------------------------------------------------------------
//--- Google Oauth and Google Sheets
//----------------------------------------------------------------------------------------------
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'pub.devrel:easypermissions:0.2.1'
implementation('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-sheets:v4-rev465-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
sourceSets {
main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'
}
}
I tried to align it with playservices ie. 17.0.0 , also tried 18.x versions to no avail. Funny that it worked when I used the Firebase Realtime Database, so no incompatibility there. But I want to switch over to Firestore to take advantage of better ArrayList handling in the classes I want to write/read.
I also had to exclude the guava group or I would get those 'Duplicated class' errors (again, only with Firestone, not with the database).
Here is the full logcat:
2019-07-06 12:12:48.397 1671-1684/? E/memtrack: Couldn't load memtrack module
2019-07-06 12:12:48.541 7857-7857/com.mairyu.app.lingoflash E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mairyu.app.lingoflash, PID: 7857
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore##18.0.0:379)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoSuchMethodError: No static method checkArgument(ZLjava/lang/String;I)V in class Lcom/google/common/base/Preconditions; or its super classes (declaration of 'com.google.common.base.Preconditions' appears in /data/app/com.mairyu.app.lingoflash-_VKmE7anO3pKy3BbdIRr4w==/base.apk)
at com.google.firebase.Timestamp.validateRange(com.google.firebase:firebase-firestore##18.0.0:160)
at com.google.firebase.Timestamp.<init>(com.google.firebase:firebase-firestore##18.0.0:65)
at com.google.firebase.firestore.model.SnapshotVersion.<clinit>(com.google.firebase:firebase-firestore##18.0.0:26)
at com.google.firebase.firestore.local.SQLiteQueryCache.<init>(com.google.firebase:firebase-firestore##18.0.0:40)
at com.google.firebase.firestore.local.SQLitePersistence.<init>(com.google.firebase:firebase-firestore##18.0.0:111)
at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore##18.0.0:226)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore##18.0.0:114)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(Unknown Source:8)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore##18.0.0:311)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(Unknown Source:2)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$3(com.google.firebase:firebase-firestore##18.0.0:287)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore##18.0.0:205)
at java.lang.Thread.run(Thread.java:764)
In my very similar case the problem was because I haven't tried to exclude Guava from some dependency except Firestore. So at first I had similar implementation (just with newer version)
implementation ('com.google.firebase:firebase-firestore:21.3.1') {
exclude group: 'com.google.guava'
}
, but then I tried to move exclusion to the other dependency where it was affordable and acceptable. For me it was google api client:
implementation ('com.google.api-client:google-api-client:1.22.0') {
exclude group: 'com.google.guava'
}
Therefore, I left Firestore dependency without exclusions and it's just working fine now.
implementation 'com.google.firebase:firebase-firestore:21.3.1'
While migrating to the new Places SDK, I faced this error:
java.lang.NoSuchMethodError: No direct method <init>(Ljava/io/InputStream;J)V in class Lcom/android/volley/toolbox/DiskBasedCache$CountingInputStream; or its super classes (declaration of 'com.android.volley.toolbox.DiskBasedCache$CountingInputStream' appears in /data/app/com.xx.xxx-SfwuN0IipN88dVqeHkiSvQ==/base.apk)
at com.android.volley.toolbox.DiskBasedCache.initialize(DiskBasedCache.java:166)
at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:84)
I'm using volley (which is imported as a project) in my app. I figure the crash is occurring due to a version conflict?
I just needed to exclude volley from the places library to make it work.
Before:
dependencies {
implementation 'com.google.android.libraries.places:places:1.0.0'
}
After:
implementation ('com.google.android.libraries.places:places:1.0.0' ){
exclude module: 'volley'
}