I try to implement firestore on my android project. I have follow everything on the official firebase wesbite. I am getting those errors :
2020-11-03 19:38:47.569 8695-8760/com.example.alllerrr E/AndroidRuntime: FATAL EXCEPTION: grpc-okhttp-0
Process: com.example.alllerrr, PID: 8695
java.lang.AssertionError: Method getAlpnSelectedProtocol not supported for object SSL socket over Socket[address=firestore.googleapis.com/172.217.19.234,port=443,localPort=46122]
at io.grpc.okhttp.internal.OptionalMethod.invoke(OptionalMethod.java:114)
at io.grpc.okhttp.internal.OptionalMethod.invokeWithoutCheckedException(OptionalMethod.java:135)
at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.getSelectedProtocol(OkHttpProtocolNegotiator.java:183)
at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.negotiate(OkHttpProtocolNegotiator.java:145)
at io.grpc.okhttp.OkHttpTlsUpgrader.upgrade(OkHttpTlsUpgrader.java:63)
at io.grpc.okhttp.OkHttpClientTransport$4.run(OkHttpClientTransport.java:571)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
I have implemented okhttp and put
<uses-permission android:name="android.permission.INTERNET"/>
on the manifest file. But nothing is working: the app is still crashing. Here is my code:
val userID = auth.currentUser
db.collection("users").document(userID.toString())
val Map = hashMapOf<String, Any>()
Map["pseudo"] = name.toString()
db.collection("users")
.add(Map)
.addOnSuccessListener { documentReference ->
Toast.makeText(baseContext, "succes:" + userID,
Toast.LENGTH_SHORT).show()
}
.addOnFailureListener { e ->
Toast.makeText(baseContext, "Veuillez essayer plus tard.",
Toast.LENGTH_SHORT).show()
}
(I have tried tu put String instead of the "Any" in the hashmap variable.) If anyone have a clue!
I experienced the same thing on android 11 and got around it by adding the following to my build.gradle
file
implementation "io.grpc:grpc-okhttp:1.32.2"
as the below answer add in android/app/build.gradle in dependencies section
dependencies {
....
.....
implementation "io.grpc:grpc-okhttp:1.32.2"
}
I did try a solution from Joseph Geoffery
build.gradle
file in your app folderimplementation "io.grpc:grpc-okhttp:1.32.2"
this work for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With