firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

firebase-sessions 1.2.4 is not compatible with datastore-preferences 1.1.0

Open SelvinPL opened this issue 9 months ago • 3 comments

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 2023.2.1 Patch 2
  • Firebase Component: don't know exacly ... i'm using crashlytics and messaging
  • Component version: see bellow

[REQUIRED] Step 3: Describe the problem

with component version as

firebase-core = "21.1.1"
firebase-crashlytics = "18.6.4"
firebase-messaging = "23.4.1"

and

datastore-preferences = "1.1.0"

Application crash at the start with

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/datastore/preferences/PreferenceDataStoreDelegateKt;
	at com.google.firebase.sessions.settings.SessionsSettings.<clinit>(SessionsSettings.kt:149)
	at com.google.firebase.sessions.FirebaseSessionsRegistrar.getComponents$lambda-3(FirebaseSessionsRegistrar.kt:87)
	at com.google.firebase.sessions.FirebaseSessionsRegistrar.$r8$lambda$FCiG63jqx5Mf3dod-mkZXs23qnc(Unknown Source:0)
	at com.google.firebase.sessions.FirebaseSessionsRegistrar$$ExternalSyntheticLambda3.create(D8$$SyntheticClass:0)
	at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0(ComponentMonitor.java:38)
	at com.google.firebase.tracing.ComponentMonitor$$ExternalSyntheticLambda0.create(D8$$SyntheticClass:0)
	at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0$com-google-firebase-components-ComponentRuntime(ComponentRuntime.java:160)
	at com.google.firebase.components.ComponentRuntime$$ExternalSyntheticLambda2.get(D8$$SyntheticClass:0)
	at com.google.firebase.components.Lazy.get(Lazy.java:53)
	at com.google.firebase.components.ComponentContainer.get(ComponentContainer.java:48)
	at com.google.firebase.components.RestrictedComponentContainer.get(RestrictedComponentContainer.java:105)
	at com.google.firebase.sessions.FirebaseSessionsRegistrar.getComponents$lambda-0(FirebaseSessionsRegistrar.kt:52)
	at com.google.firebase.sessions.FirebaseSessionsRegistrar.$r8$lambda$me3-yZC2pOH9X-lURhz9tK7161I(Unknown Source:0)
	at com.google.firebase.sessions.FirebaseSessionsRegistrar$$ExternalSyntheticLambda0.create(D8$$SyntheticClass:0)
	at com.google.firebase.tracing.ComponentMonitor.lambda$processRegistrar$0(ComponentMonitor.java:38)
	at com.google.firebase.tracing.ComponentMonitor$$ExternalSyntheticLambda0.create(D8$$SyntheticClass:0)
	at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0$com-google-firebase-components-ComponentRuntime(ComponentRuntime.java:160)
	at com.google.firebase.components.ComponentRuntime$$ExternalSyntheticLambda2.get(D8$$SyntheticClass:0)
	at com.google.firebase.components.Lazy.get(Lazy.java:53)
	at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:322)
	at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:312)
	at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:607)
	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:300)
	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:264)
	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:249)
	at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
	at android.content.ContentProvider.attachInfo(ContentProvider.java:2404)
	at android.content.ContentProvider.attachInfo(ContentProvider.java:2374)
	at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
	at android.app.ActivityThread.installProvider(ActivityThread.java:7422)
	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6939)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6710)
	at android.app.ActivityThread.access$1500(ActivityThread.java:247)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7839)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

while with datastore-preferences = "1.0.0" all working fine (besides fact that I cannot use 1.0.0 with java code which I preffer)

Steps to reproduce:

I'm 99% sure that when you would take any project using any firebase's component which depends on com.google.firebase.sessions.settings.SessionsSettings it would behave in the same way

Relevant Code:

I belive that code is irrelevant ... it is just incompatibility between datastore-preferences 1.0.0 and datastore-preferences 1.1.0

SelvinPL avatar Apr 30 '24 12:04 SelvinPL

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Apr 30 '24 12:04 google-oss-bot

Hi @SelvinPL, thank you for reaching out. I tried reproducing the issue by overriding the current datastore-preference 1.0.0 dependency to datastore-preference 1.0.0, however, I wasn't able to encounter the error.

To clarify, the Firebase Session is used by Crashlytics and Performance internally to measure sessions. Were you able to reproduce the issue? Could you share an MCVE to help us investigate the issue?

lehcar09 avatar Apr 30 '24 17:04 lehcar09

seems like it is crashlytics minimal example:

topmost build.gradle

buildscript {
    
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.3.2'
        classpath 'com.google.gms:google-services:4.4.1'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

main build.gradle

apply plugin: 'com.android.application'

android {
    buildToolsVersion = '34.0.0'
    namespace "com.example"

    defaultConfig {
        compileSdk 34
        applicationId "com.example"
        minSdkVersion 22
        targetSdkVersion 34
        versionCode 1000003
        versionName "1.0.3"
    }

    signingConfigs {
        release {
            storeFile file(...)
            storePassword ...
            keyAlias ...
            keyPassword ...
        }
    }

    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug{
            debuggable true
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    implementation "androidx.datastore:datastore-preferences:1.1.0"
    implementation "com.google.firebase:firebase-crashlytics:18.6.4"
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <application android:allowBackup="true"  >
        <activity android:name=".MainActivity" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.java

package com.example;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;


public class MainActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new Button(this));
	}
}

gradle.properties

org.gradle.jvmargs=-Xmx3g
org.gradle.caching=true
android.useAndroidX=true

SelvinPL avatar May 01 '24 09:05 SelvinPL

My app is crashing with the very same exact crash log as commented by the OP, all I just done was to upgrade implementation 'androidx.datastore:datastore-preferences-rxjava3:1.0.0' to implementation 'androidx.datastore:datastore-preferences-rxjava3:1.1.0' the crash is not random, but consistent on all tested devices.

EzequielAdrianM avatar May 02 '24 10:05 EzequielAdrianM

Hi folks! I still wasn't able to reproduce the issue when using the androidx.datastore:datastore-preferences-rxjava3:1.1.0 or androidx.datastore:datastore-preferences:1.1.0. I have create an MCVE to replicate the issue, am I missing anything?

lehcar09 avatar May 02 '24 15:05 lehcar09

I'm using java not kotlin. And example was in java. Maybe this is culprit

SelvinPL avatar May 02 '24 16:05 SelvinPL

There was a prior discussion around this issue, I'm linking it here for visibility: #5176 (the fix that was implemented back then was reverted at some point because it caused a different issue)

thatfiredev avatar May 02 '24 23:05 thatfiredev

seems to be working fine with 8.4.0 build tools ... closing

SelvinPL avatar May 06 '24 09:05 SelvinPL

Yes, thanks.

EzequielAdrianM avatar May 06 '24 14:05 EzequielAdrianM