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.
Android app crashes when i run these two things together - OkHttpStack as base stack for new request queue in volley and firebase firestore dependency in gradle ('com.google.firebase:firebase-firestore:17.0.5')
Gives me this error, maybe firebase firestore dependency already includes okhttp dependency that's why this coming or maybe its not, but if this is the case what to be done or how to exclude it? or Otherwise i am not getting what the error is, please suggest a solution.
Dependencies -
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
implementation 'com.google.firebase:firebase-firestore:17.0.5'
FATAL EXCEPTION: Thread-21
java.lang.NoSuchMethodError: No direct method <init>(Lcom/squareup/okhttp/OkHttpClient;Lcom/squareup/okhttp/Request;ZZZLcom/squareup/okhttp/Connection;Lcom/squareup/okhttp/internal/http/RouteSelector;Lcom/squareup/okhttp/internal/http/RetryableSink;Lcom/squareup/okhttp/Response;)V in class Lcom/squareup/okhttp/internal/http/HttpEngine; or its super classes (declaration of 'com.squareup.okhttp.internal.http.HttpEngine' appears in /data/app/packagename-vaVP5bn4ajPlEZQZDBqyVg==/split_lib_dependencies_apk.apk:classes2.dex)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:362)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:312)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:377)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:96)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:123)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
UncaughtException: java.lang.NoSuchMethodError: No direct method <init>(Lcom/squareup/okhttp/OkHttpClient;Lcom/squareup/okhttp/Request;ZZZLcom/squareup/okhttp/Connection;Lcom/squareup/okhttp/internal/http/RouteSelector;Lcom/squareup/okhttp/internal/http/RetryableSink;Lcom/squareup/okhttp/Response;)V in class Lcom/squareup/okhttp/internal/http/HttpEngine; or its super classes (declaration of 'com.squareup.okhttp.internal.http.HttpEngine' appears in /data/app/packageName-vaVP5bn4ajPlEZQZDBqyVg==/split_lib_dependencies_apk.apk:classes2.dex)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:362)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:312)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:377)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:96)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:123)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
Firestore depends on old okhttp:2.7.2, not okhttp3. It's even enother package, not just version. So you cant just exclude it from firestore dependencies. The only way I see here - you should switch to old version of okhttp until firestore update its dependencies.
There is a temporary fix at here
configurations.all {
resolutionStrategy {
force 'com.squareup.okhttp:okhttp:2.7.5'
force 'com.squareup.okio:okio:1.17.5'
}
}
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.augmentedreality.projectar. Make sure to call FirebaseApp.initializeApp(Context) first.
For the past 48 hours I've been stuck at this Exception, and so far has no clue what's possibly causing this, I've referred all these answers:
Default FirebaseApp is not initialized
Getting “Default FirebaseApp is not initialized in this process” despite initializing FirebaseApp while using FirebaseStorage
FirebaseApp not initializing despite FirebaseApp.initializeApp() being called in Application class
How can I solve the Android Firebase error “Default FirebaseApp is not initialised in this process”?
And yet the problem persists. I am using Firebase Storage as well as Firebase Database. I use Firebase storage to download image using a Service. The Service is same as the Firebase quick start example from Github[here].
Now, the exception is thrown at this line :
mStorageRef = FirebaseStorage.getInstance().getReferenceFromUrl("https://firebasestorage.googleapis.com/v0/b/xxxxxxx-xx-xxxxxx.appspot.com/o/Coca-Cola.jpg?alt=media&token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
Based on the answers mentioned in the aforementioned questions, I've made the following changes:
1)AppMain.java
public class AppMain extends Application {
#Override
public void onCreate() {
super.onCreate();
FirebaseApp.initializeApp(this);
Firebase.setAndroidContext(this);
//if(!FirebaseApp.getApps(this).isEmpty()) {
// FirebaseDatabase.getInstance().setPersistenceEnabled(true);
//}
}
}
2) Dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.google.android.gms:play-services:10.0.0'
}
Question: How to fix this issue?
Remove
FirebaseApp.initializeApp(this);
Firebase.setAndroidContext(this);
compile 'com.firebase:firebase-client-android:2.5.2+'
you dont need them..
use
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.android.gms:play-services:10.0.1'
private DatabaseReference mDatabase;
// ...
mDatabase = FirebaseDatabase.getInstance().getReference();
instead,
for full instructions -
Firebase Docs
Instead of modifying this code,
You should update the Android studio version. May be your problem will be solved.
After having started using Firebase for event logging in my android app I keep getting these error messages when I fire up my app:
E/System: java.lang.IllegalStateException: The database '/...folder here.../google_app_measurement_local.db' is not open.
at android.database.sqlite.SQLiteDatabase.throwIfNotOpenLocked(SQLiteDatabase.java:2169)
at android.database.sqlite.SQLiteDatabase.createSession(SQLiteDatabase.java:365)
at android.database.sqlite.SQLiteDatabase$1.initialValue(SQLiteDatabase.java:84)
at android.database.sqlite.SQLiteDatabase$1.initialValue(SQLiteDatabase.java:83)
at java.lang.ThreadLocal$Values.getAfterMiss(ThreadLocal.java:430)
at java.lang.ThreadLocal.get(ThreadLocal.java:65)
at android.database.sqlite.SQLiteDatabase.getThreadSession(SQLiteDatabase.java:359)
at android.database.sqlite.SQLiteProgram.getSession(SQLiteProgram.java:101)
at android.database.sqlite.SQLiteQuery.setLastStmt(SQLiteQuery.java:96)
at android.database.sqlite.SQLiteQuery.close(SQLiteQuery.java:111)
at android.database.sqlite.SQLiteCursor.close(SQLiteCursor.java:300)
at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:366)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:202)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185)
at java.lang.Thread.run(Thread.java:818)
Here's a snippet from my build.gradle:
dependencies {
compile 'com.android.support:support-v4:25.0.0'
compile 'com.google.firebase:firebase-analytics:9.8.0'
compile 'com.google.firebase:firebase-crash:9.8.0'
compile files('src/main/resources/simple-xml-2.7.jar')
compile files('src/main/resources/date4j.jar')
compile 'com.android.support:appcompat-v7:25.0.0'
compile files('src/main/resources/picasso-2.5.2.jar')
}
All I do is call
_firebaseAnalytics = FirebaseAnalytics.getInstance(context);
and then
_firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SHARE, payload);
I have not been able to find any solutions online and am now hoping for help here...
Please move to latest version of firebase SDK. Firebase solved this memory leak issue in their updated sdk. Remove your old SDK and add below line in your gradle file.
compile 'com.google.firebase:firebase-core:11.0.1'
I have just faced with this when enabling strictmode, when adding
compile 'com.google.firebase:firebase-core:9.8.0'
I had to use earlier version:
compile 'com.google.firebase:firebase-core:9.6.0'
I've found latest version from Firebase Android SDK Release Notes
I'm using the latest firebase(9.0.2):
build.gradle:
dependencies {
...
compile "com.google.firebase:firebase-database:9.0.2"
compile 'com.google.firebase:firebase-auth:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
Project build.gradle
classpath 'com.google.gms:google-services:3.0.0'
And after some time application starts crashing with this Exception:
Fatal Exception: java.lang.RuntimeException: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
at com.google.android.gms.internal.zzadp$1$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5274)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by java.lang.AssertionError: hardAssert failed:
at com.google.android.gms.internal.zzaiv.zzb(Unknown Source)
at com.google.android.gms.internal.zzaiv.zzaN(Unknown Source)
at com.google.android.gms.internal.zzagh.zzb(Unknown Source)
at com.google.android.gms.internal.zzagh.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzadp.zza(Unknown Source)
at com.google.android.gms.internal.zzaeu.zzic(Unknown Source)
at com.google.android.gms.internal.zzafc.zzRy(Unknown Source)
at com.google.android.gms.internal.zzafc.zza(Unknown Source)
at com.google.android.gms.internal.zzafc$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
in onCreate of Application I have:
#Override
public void onCreate() {
...
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
}
and also we created singleton helper class for Firebase what called from Activities(all activities in the same process)/Fragments:
private FirebaseHelper() {
mFirebaseRef = FirebaseDatabase.getInstance().getReference();
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseAuth.addAuthStateListener(this);
authentication();
}
public static synchronized FirebaseHelper getInstance() {
if (mInstance == null || mInstance.getFirebaseRef() == null) {
mInstance = new FirebaseHelper();
}
return mInstance;
}
Libraries:
dependencies {
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.5.6#aar') {
transitive = true;
}
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.google.android.gms:play-services-base:9.0.2'
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.android.gms:play-services-appindexing:9.0.2'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.11.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.amazonaws:aws-android-sdk-core:2.2.12'
compile 'com.amazonaws:aws-android-sdk-cognito:2.2.12'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.5'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.github.curioustechizen.android-ago:library:1.3.0'
compile 'com.cedarsoftware:json-io:4.4.0'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3#aar'
compile 'joda-time:joda-time:2.9.3'
compile 'com.facebook.fresco:fresco:0.10.0'
compile 'com.facebook.fresco:imagepipeline-okhttp3:0.10.0'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-invites:9.0.2'
compile 'com.google.firebase:firebase-database:9.0.1'
compile 'com.google.firebase:firebase-auth:9.0.1'
compile 'com.github.jd-alexander:LikeButton:0.2.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
compile files('libs/core-3.2.1.jar')
}
UPDATE: It turns out there's another cause of this symptom, as mentioned by Kristijan in the comments. We've identified a bug where if you have a startAt() or endAt() call with an integer endpoint, e.g. startAt(10), it can trigger this sort of cache corruption. This bug will be fixed in the next release of the SDK. In the meantime, you may be able to use non-integer endpoints, e.g. startAt(10.001), as a workaround.
These symptoms match a known limitation with Firebase Realtime Database that prevents it from working if you have persistence enabled in multiple processes in an Android app.
Note that any Application.onCreate() code will run for every process in a multi-process android app, and so if your app is multi-process, you are initializing Firebase Database with persistence enabled in multiple processes and this is liable to lead to corruption of our offline cache and the hardAssert error that you are reporting.
Keep in mind that sometimes your app may be multi-process without you realizing it. For instance if you're using firebase-crash, it currently creates a background process for the purpose of reporting crashes more reliably, and so if you use firebase-crash, you now have a multi-process app. Other 3rd-party libraries could have similar behavior.
To test, you could add code to your Application.onCreate() something like:
System.out.println('INITIALIZING APP FROM PID: ' + android.os.Process.myPid());
If you see that logged twice in logcat (with two different PIDs) that means your app is running with multiple processes and you're hitting the limitation I mentioned.
As a workaround, you can either:
Modify your app so that it only uses a single process.
Remove your setPersistenceEnabled() code from your Application class and put it somewhere that will only be executed in your main process.
Note that you'll likely need to clear your app data to get rid of the hardAssert error once you've hit it, as the error indicates that the offline cache has gotten into an invalid state, so to fix it, you must clear it completely.
In an upcoming release, we have added better detection of this scenario so you'll get a much better error message. Additionally, firebase-crash will in the future avoid spawning a 2nd process, which may make this less likely to be an issue.
I know it is an old post , i faced this issue and after some research , i upgraded my gradle to :
implementation 'com.google.firebase:firebase-database:18.0.1'
This helped the error go away. use the latest library.
This Solved My Problem.
We are facing the same issue on version 9.0.2 and 9.2.0. After many hours of investigation, we found that one way to reproduce this issue is to have a query with fixed endAt and startAt parameters. Let me explain with a sample code:
// Firebase dependencies
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'
...
public class MainActivity extends AppCompatActivity {
private FirebaseDatabase m_Database;
private static boolean s_persistenceInitialized = false;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
m_Database = FirebaseDatabase.getInstance();
if (!s_persistenceInitialized) {
m_Database.setPersistenceEnabled(true);
s_persistenceInitialized = true;
}
m_Database.setLogLevel(Level.DEBUG);
}
#Override
protected void onStart() {
super.onStart();
long endAt = 100L; // Fixed value: CRASH on third app restart
// long endAt = new Date().getTime(); // Dynamic value: NO CRASH
getGoal("min_per_day", endAt, "some_uid");
}
private void getGoal(String p_goalId, long p_endAt, String p_uid) {
Query ref = m_Database.getReference("v0/data/meditation/goals").child(p_goalId).child(p_uid)
.orderByChild("time").endAt(p_endAt).limitToLast(1);
ref.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("FB", "Snapshot: " + dataSnapshot);
}
#Override
public void onCancelled(DatabaseError error) {
Log.e("FB", "Error: " + error);
}
});
}
}
So the fixed endAt param will crash the app on third start. I assume queries are cached to disk and then corrupted at some point if we recreate the same query from local cache multiple times (three). On the other hand, if endAt is not fixed, for example current time in millis, then everything works as expected. The same applies for startAt query parameter.
I too faced the same issue; After some point of time application was keep crashing on every launch.
For time being I've disabled this database persistance. FirebaseDatabase.getInstance().setPersistenceEnabled(true).
I don't see any such strange crashes now!
Hope Firebase team will resolve this issue soon.
This issue has been fixed in version 9.6. Check out the release notes.
However, when we enable the offline capabilities internet connection is still required for our app. Otherwise, write (at least) callbacks are never called.
Just for the record:
We solved the Uncaught exception in Firebase runloop (3.0.0) by removing following line
//remove this "feature" if you should use it
FirebaseApp.setAutomaticResourceManagmentEnabled(true)
API description:
If set to true it indicates that Firebase should close database
connections automatically when the app is in the background. Disabled
by default.
(Might be, that we missed some configurations for correct usage of this feature, but App is working as expected after not enabling the ResourceManagment)
This fault is not from firebase, i simply got mine fixed by solving an uncaught NullPointerException in my program. Because when it throws an Exception while currently using firebase library, it misleads to firebase AssertionError.
You need to debug your project carefully to solve this problem.
And this seem to be compiler issue. However, you should try downgrading your Android Gradle Plugin to match the expected firebase library version i suspect.
I have this problem, this method work if the install is new, and this method work if put the code how:
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseDatabase database = FirebaseDatabase.getInstance();
But if test in other device you need uninstall the app