-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore can not connect to server when using firebase-firestore and firebase-inappmessaging-display in same project in KitKAT #244
Comments
@rakeshdausa Does Firestore fail 100% of the time for you? And if you remove Firebase In-App Messaging does the Firestore connection work immediately? |
I'm able to reproduce this. (I took the firestore quickstart, added "implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.5'" and ran on a kitkat emulator. Once fiam is added, the firestore connection fails with the above stacktrace. The issue does not occur on my oreo emulator.) |
@rsgowman FIAM is built on OkHTTP while Firestore uses gRPC, could it be that those two share a common dependency and FIAM is pulling in the wrong version? |
Nothing immediately jumps out. Both depend on "com.squareup.okhttp:okhttp:2.7.5". Firestore additionally depends on some grpc components (1.16.1). But it's a good bet that somewhere around there is where the problem is. Tracing through the code on a K emulator (and an L emulator, which works fine), I can see that all ssl connections end up going to io.grpc.okhttp.OkHttpProtocolNegotiator. In the negotiate() method, they both call sslSocket.startHandshake(). On K, this fails with the stacktrace. On L this succeeds. On K, both the FIAM and Firestore connections fail, so it's not just Firestore that's broken. |
Yes |
Hey, Is there any way so I can just use both inappmessaging and firestore with some dependency exclude? |
Hi @rakeshdausa; Sorry about the slow response. This was a rather involved issue. The good news is that I think we've finally tracked down the root cause... But the bad news is that we don't have a solution just yet. I'll update here again as soon as I have more info. |
Ok; we've got this figured out. We'll work on getting a fix ready, but in the meantime, I've got a workaround that you can use to unblock yourself. I wouldn't recommend using this in a production app (at least, not without a little more cleanup) but it should be fine for development purposes. The underlying issue is that Firestore and Functions can't agree as to which ciphers should be used. (Hence 'no ciphers available' in the stack trace.) We can fix that by overriding the set of ciphers that they use. One minor catch: Since firebase-inappmessaging gets loaded quite early, we need to set things up such that we do this override even earlier. We can use a ContentProvider for that.
package com.example.your.package.here;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.support.annotation.Nullable;
import com.google.android.gms.security.ProviderInstaller;
public class TemporaryProviderInstallerProvider extends ContentProvider {
@Override
public boolean onCreate() {
try {
ProviderInstaller.installIfNeeded(getContext());
} catch (Exception e) {
throw new RuntimeException(e);
}
return false;
}
/* The rest of the methods in this class are irrelevant and are only present to satisfy the abstract class requirements. */
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
return null;
}
@Nullable
@Override
public String getType(Uri uri) {
return null;
}
@Nullable
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
}
<manifest ...>
<application ...>
<activity ...>
</activity>
...
<!-- Add this block -->
<provider
android:name="com.example.your.package.here.TemporaryProviderInstallerProvider"
android:authorities="${applicationId}.temporaryproviderinstallerprovider"
android:exported="false"
android:initOrder="101"/> <!-- must be greater than 100 -->
</application>
</manifest> That should do the trick. This should only be necessary for KitKat (and possibly earlier, though I haven't verified) though should be harmless on more recent versions. This workaround largely depends on certain implementation details within Firebase as a whole, so it's not necessarily guaranteed to work going forward. So the best approach is to use this for now for development purposes, but then back it out once we've this fixed in our sdks. I'll keep this issue open, and then will post back here once we've done that. Anyways, give this a try, and let me know if it works for you. |
This will be fixed in a future release of In-App Messaging. |
This was fixed in version 17.1.1 of In-App Messaging, released 2019-03-27. |
This fix actually manages to break crypto on Android 5.0 (probably 4.4) for other uses. E/NativeCrypto: Could not sign message in EcdsaMethodDoSign! |
Hi @laszlo-major, Could you share more details about what you're doing? A minimal app that reproduces the issue would be ideal, but elaborating on 'other uses' might be enough. I'd be curious as to your list of dependencies too. |
In particular note that Firestore has been installing this crypto provider since it was released. The fix, such as it was, was to have firebase-inappmessaging-display do the same thing. We didn't change anything in Firestore. |
I am creating a JWT and signing it with ECDSA256 using https://github.com/jwtk/jjwt. Works fine until I upgrade inappmessaging, then throws the error above. I am not using firestore, I came to the Provider install conclusion based on https://groups.google.com/forum/#!msg/google-sites-api/SL4e-wddUlU/Wjq64N25EQAJ and the fact that updating inappmessaging from 17.0.4 to 17.1.1 causes the failure. List of dependencies:
|
I was facing the same issue with FirebaseML kit, it was working for almost 6 months and suddenly it stopped to call any cloud vision or firebase ml cloud function, so I did this on my app start
Just call this function before any network calls and it will works probably |
firebase google sign in authentication failed android: |
@faiza2666 The failure you're describing appears to be unrelated to the issue in this thread. Can you please open a new issue for this? Additionally, please provide:
|
Hi,
I am using firestore in my project from last 3 months and it was working perfectly in All Kitkat devices but now i Integrated firebase-inappmessaging-display also and firestore stops working in kitkat devices with following error
following are the dependencies that I am using,
The text was updated successfully, but these errors were encountered: