Skip to content
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

Datastore window crashes #297

Open
DarkAbhi opened this issue Dec 13, 2023 · 2 comments
Open

Datastore window crashes #297

DarkAbhi opened this issue Dec 13, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@DarkAbhi
Copy link

DarkAbhi commented Dec 13, 2023

Describe the bug
Clicking on datastore preferences crashes the app.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Pluto screen
  2. Click on datastore

Expected behavior
It should open datastore screen

Smartphone (please complete the following information):

  • Device: Samsung S21
  • OS: Android 13

Datastore Repository:

// Constant to hold the name of the DataStore
const val PREFERENCE_NAME = "AGRIAPP_DATASTORE"

/**
 * Extension property on Context to easily access the DataStore instance.
 */
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = PREFERENCE_NAME)

/**
 * Repository class to interact with DataStore.
 *
 * @property context Application context injected using Dagger/Hilt.
 */
class DataStoreRepository @Inject constructor(
    @ApplicationContext private val context: Context,
) {

    // Access the DataStore instance from context
    private val dataStore = context.dataStore

    // Object to hold the keys for the preferences
    private object PreferenceKeys {
        // Key for storing the cart amount
        val currentCartAmount = intPreferencesKey("cart_amount")
    }

    /**
     * Suspend function to save cart amount to DataStore.
     *
     * @param amount The cart amount to be saved.
     */
    suspend fun saveCartAmount(amount: Int) {
        dataStore.edit { preference ->
            // Saves the cart amount in DataStore
            preference[PreferenceKeys.currentCartAmount] = amount
        }
    }

    // Flow to read the cart amount from DataStore
    val readCartAmount: Flow<Int> = dataStore.data.catch { exception ->
        // If an IOException occurs, emit empty preferences, else throw the exception
        if (exception is IOException) {
            emit(emptyPreferences())
        } else {
            throw exception
        }
    }.map { preference ->
        // Read the cart amount from preferences, default to 0 if not set
        preference[PreferenceKeys.currentCartAmount] ?: 0
    }
}

Application Class

override fun onCreate() {
        super.onCreate()
        if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())

        Pluto.Installer(this)
            .addPlugin(PlutoNetworkPlugin())
            .addPlugin(PlutoExceptionsPlugin())
            .addPlugin(PlutoSharePreferencesPlugin())
            .addPlugin(PlutoDatastorePreferencesPlugin())
            .install()

        PlutoDatastoreWatcher.watch(PREFERENCE_NAME, this.dataStore)
}

Crash log

java.lang.NoSuchMethodError: No static method Fixed(I)Landroidx/constraintlayout/core/state/Dimension; in class Landroidx/constraintlayout/core/state/Dimension; or its super classes (declaration of 'androidx.constraintlayout.core.state.Dimension' appears in /data/app/~~8eFVLsu_xlYEB40RP5fS7g==/com.criyagen.test-fuhYnKul_0EVdbl4M4WA-Q==/base.apk)
	at androidx.constraintlayout.compose.Measurer.performMeasure-DjhGOtQ(ConstraintLayout.kt:1201)
	at androidx.constraintlayout.compose.ConstraintLayoutKt$rememberConstraintLayoutMeasurePolicy$1$measurePolicy$1.measure-3p2s80s(ConstraintLayout.kt:110)
	at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103)
	at androidx.compose.foundation.layout.FillModifier.measure-3p2s80s(Size.kt:658)
	at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:323)
	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1090)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2200)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:234)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:230)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:230)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:120)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:107)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:342)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:321)
	at androidx.compose.foundation.layout.RowColumnMeasurementHelper.measureWithoutPlacing-_EkL_-Y(RowColumnMeasurementHelper.kt:112)
	at androidx.compose.foundation.layout.RowColumnImplKt$rowColumnMeasurePolicy$1.measure-3p2s80s(RowColumnImpl.kt:70)
	at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103)
	at androidx.compose.foundation.layout.FillModifier.measure-3p2s80s(Size.kt:658)
	at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:323)
	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1090)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2200)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:234)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:230)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:230)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:120)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:107)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:342)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:321)
	at androidx.compose.foundation.layout.RowColumnMeasurementHelper.measureWithoutPlacing-_EkL_-Y(RowColumnMeasurementHelper.kt:112)
	at androidx.compose.foundation.layout.RowColumnImplKt$rowColumnMeasurePolicy$1.measure-3p2s80s(RowColumnImpl.kt:70)
	at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103)
	at androidx.compose.foundation.layout.PaddingModifier.measure-3p2s80s(Padding.kt:364)
	at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:323)
	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1090)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2200)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:234)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:230)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:230)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:120)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:107)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:342)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:321)
	at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1.measure-3p2s80s(Box.kt:137)
	at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103)
	at androidx.compose.foundation.layout.FillModifier.measure-3p2s80s(Size.kt:658)
	at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:323)
	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155)
	at androidx.compose.foundation.layout.FillModifier.measure-3p2s80s(Size.kt:658)
	at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:323)
	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1090)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2200)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:234)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:230)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:230)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:120)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:107)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:342)
	at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1187)
	at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default(LayoutNode.kt:1178)
	at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:309)
	at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureOnly(MeasureAndLayoutDelegate.kt:479)
	at androidx.compose.ui.node.MeasureAndLayoutDelegate.recurseRemeasure(MeasureAndLayoutDelegate.kt:357)
	at androidx.compose.ui.node.MeasureAndLayoutDelegate.recurseRemeasure(MeasureAndLayoutDelegate.kt:361)
	at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureOnly(MeasureAndLayoutDelegate.kt:348)
	at androidx.compose.ui.platform.AndroidComposeView.onMeasure(AndroidComposeView.android.kt:881)
	at android.view.View.measure(View.java:27731)
	at androidx.compose.ui.platform.AbstractComposeView.internalOnMeasure$ui_release(ComposeView.android.kt:302)
	at androidx.compose.ui.platform.AbstractComposeView.onMeasure(ComposeView.android.kt:289)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
	at android.view.View.measure(View.java:27731)
	at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:861)
	at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.measure(BasicMeasure.java:491)
	at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.measureChildren(BasicMeasure.java:140)
	at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:285)
	at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:119)
	at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1670)
	at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1813)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
	at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:145)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
	at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
	at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
	at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
	at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
	at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1379)
	at android.view.View.measure(View.java:27731)
	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4841)
	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:3426)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3732)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3116)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10885)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1301)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
	at android.view.Choreographer.doCallbacks(Choreographer.java:923)
	at android.view.Choreographer.doFrame(Choreographer.java:852)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8762)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
@DarkAbhi DarkAbhi added the bug Something isn't working label Dec 13, 2023
@govinddixit-cred
Copy link
Contributor

@DarkAbhi we have fixed this issue in the latest release of pluto (v2.2.1), you can try bumping the pluto version of your project

@srtvprateek we can close this issue

@DarkAbhi
Copy link
Author

DarkAbhi commented Jan 15, 2024

Amazing, will check.
Update: @govinddixit-cred it still crashes.

This is what I have:

    debugImplementation 'com.plutolib:pluto:2.2.1'
    releaseImplementation 'com.plutolib:pluto-no-op:2.2.1'

    debugImplementation 'com.plutolib.plugins:bundle-core:2.2.1'
    releaseImplementation 'com.plutolib.plugins:bundle-core-no-op:2.2.1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants