21

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!

3
  • 1
    github.com/grpc/grpc-java/issues/2703 Commented Nov 3, 2020 at 19:04
  • Well it cannot be because of the version or age of the phone I'm using, it's android 11... My google play services is up to date so that's why I don't understand... Commented Nov 3, 2020 at 19:45
  • As the link Doug provided indicated that you should use the dynamic security provider Commented Nov 7, 2020 at 20:44

3 Answers 3

54

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"

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, this works for me! insert in android/app/build.gradle
11

as the below answer add in android/app/build.gradle in dependencies section

dependencies { .... ..... implementation "io.grpc:grpc-okhttp:1.32.2" } 

Comments

0

I did try a solution from Joseph Geoffery

  • Open build.gradle file in your app folder
  • Add this in dependencies section
    implementation "io.grpc:grpc-okhttp:1.32.2" 

this work for me

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.