SuddenH4X / awesome-app-rating

An Android library providing a dialog, which asks the user to rate the app or give feedback. You can also use the library to show the Google in-app review easily under certain conditions.
Apache License 2.0
231 stars 39 forks source link

Parcelable encountered IOException writing serializable object (name = com.suddenh4x.ratingdialog.dialog.DialogOptions) #50

Closed Monabr closed 3 years ago

Monabr commented 3 years ago
Fatal Exception: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.suddenh4x.ratingdialog.dialog.DialogOptions)
       at android.os.Parcel.writeSerializable(Parcel.java:1836)
       at android.os.Parcel.writeValue(Parcel.java:1783)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.os.Parcel.writeBundle(Parcel.java:1000)
       at androidx.fragment.app.FragmentState.writeToParcel(FragmentState.java:125)
       at android.os.Parcel.writeTypedObject(Parcel.java:1637)
       at android.os.Parcel.writeTypedList(Parcel.java:1516)
       at android.os.Parcel.writeTypedList(Parcel.java:1473)
       at androidx.fragment.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:58)
       at android.os.Parcel.writeParcelable(Parcel.java:1804)
       at android.os.Parcel.writeValue(Parcel.java:1710)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.os.Parcel.writeBundle(Parcel.java:1000)
       at android.os.Parcel.writeValue(Parcel.java:1701)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.os.Parcel.writeBundle(Parcel.java:1000)
       at android.os.Parcel.writeValue(Parcel.java:1701)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4627)
       at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:224)
       at android.app.ActivityThread.main(ActivityThread.java:7590)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Caused by java.io.NotSerializableException: com.example.example.example.MainContainerActivity
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1240)
       at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1604)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1565)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1488)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1234)
       at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1604)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1565)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1488)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1234)
       at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1604)
       at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1565)
       at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1488)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1234)
       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:354)
       at android.os.Parcel.writeSerializable(Parcel.java:1831)
       at android.os.Parcel.writeValue(Parcel.java:1783)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.os.Parcel.writeBundle(Parcel.java:1000)
       at androidx.fragment.app.FragmentState.writeToParcel(FragmentState.java:125)
       at android.os.Parcel.writeTypedObject(Parcel.java:1637)
       at android.os.Parcel.writeTypedList(Parcel.java:1516)
       at android.os.Parcel.writeTypedList(Parcel.java:1473)
       at androidx.fragment.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:58)
       at android.os.Parcel.writeParcelable(Parcel.java:1804)
       at android.os.Parcel.writeValue(Parcel.java:1710)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.os.Parcel.writeBundle(Parcel.java:1000)
       at android.os.Parcel.writeValue(Parcel.java:1701)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.os.Parcel.writeBundle(Parcel.java:1000)
       at android.os.Parcel.writeValue(Parcel.java:1701)
       at android.os.Parcel.writeArrayMapInternal(Parcel.java:931)
       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1593)
       at android.os.Bundle.writeToParcel(Bundle.java:1253)
       at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4627)
       at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:224)
       at android.app.ActivityThread.main(ActivityThread.java:7590)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
  I am using 2.3.0 and still get this issue 
Monabr commented 3 years ago

Here is my code

AppRating.Builder(this)
                .setTitleTextId(R.string.main_rate_message)
                .setConfirmButtonTextId(R.string.confirm)
                .setRateLaterButtonTextId(R.string.rate_later)
                .setRateNowButtonTextId(R.string.rate_now)
                .setShowOnlyFullStars(true)
                .setFeedbackTitleTextId(R.string.title_feedback)
                .setMailFeedbackMessageTextId(R.string.feedback_message)
                .setMailFeedbackButtonTextId(R.string.send_feedback)
                .setNoFeedbackButtonTextId(R.string.not_send_feedback)
                .setStoreRatingTitleTextId(R.string.google_play_rating)
                .setStoreRatingMessageTextId(R.string.google_play_rating_text)
                .showRateNeverButtonAfterNTimes(R.string.never, null, 1)
                .setAdditionalRateNowButtonClickListener {
                    CustomLogger.log()
                }
                .setConfirmButtonClickListener { rating ->
                    if (rating < 4) {
                        CustomLogger.log()
                    } else {
                        CustomLogger.log()
                    }
                }
                .setUseCustomFeedback(true)
                .setCustomFeedbackMessageTextId(R.string.custom_feedback_message)
                .setCustomFeedbackButtonClickListener{ feedback ->
                    CustomLogger.log(feedback)
                }
                .setRatingThreshold(RatingThreshold.FOUR)
                .setMinimumLaunchTimes(remoteConfig.getLong("param1").toInt())
                .setMinimumDays(remoteConfig.getLong("param2").toInt())
                .setMinimumLaunchTimesToShowAgain(3)
                .setMinimumDaysToShowAgain(3)
                .setCancelable(true)
                .showIfMeetsConditions()
Monabr commented 3 years ago

I start to get this bug after add this lines of code

                .setConfirmButtonClickListener { rating ->
                    if (rating < 4) {
                        CustomLogger.log()
                    } else {
                        CustomLogger.log()
                    }
                }
                .setUseCustomFeedback(true)
                .setCustomFeedbackMessageTextId(R.string.custom_feedback_message)
                .setCustomFeedbackButtonClickListener{ feedback ->
                    CustomLogger.log(feedback)
                }
                .setMinimumLaunchTimes(remoteConfig.getLong("param1").toInt())
                .setMinimumDays(remoteConfig.getLong("param2").toInt())
Monabr commented 3 years ago

Try to fix it by using

viewModel.liveData.postValue("value")

but still get this exception

SuddenH4X commented 3 years ago

Hi @Monabr,

the issue is related to #48. Probably your CustomLogger or the remoteConfig has a reference to your class MainContainerActivity. To fix it you can extract the remote config values to a local variable:

val param1 = remoteConfig.getLong("param1").toInt()
val param2 = remoteConfig.getLong("param2").toInt()

AppRating.Builder(this)
...
.setMinimumLaunchTimes(param1)
.setMinimumDays(param2)
...
.showIfMeetsConditions()

If your CustomLogger has a reference to the Activity too you can use livedata/flow/... for that.

Monabr commented 3 years ago

it can't be used like in your example in project i tryed to use it with viewmodel but it's also cause the problem. Maybe you can refactored code to LiveData so i could just observe the values and than use it?

Monabr commented 3 years ago

I also can provide you code for make liveData works only once

SuddenH4X commented 3 years ago

Can you send me a sample project, so I can look into the issue? With the currently provided information it's hard to identify the exact problem.

Monabr commented 3 years ago

@SuddenH4X What are you speaking about? I just said about 3 situations: a non-working test case, a suggestion to add a lifedate for the result or a flow, and the third one - I can give a code of a lifedate that will work only 1 time as an event.

SuddenH4X commented 3 years ago

You've posted a stacktrace and I suggested you a solution which you said isn't working. I tried to reproduce your issue but couldn't get it to crash (with my suggestion applied). Therefore I asked you to send me a sample project, so I can look into the exact issue.

I don't think it's useful to add a livedata/flow in this specific case. And I'm not sure what you mean/want exactly with "a livedata that will work only 1 time as an event". But if you have a code snippet it will help me to understand your suggestion/issue.

SuddenH4X commented 3 years ago

Duplicate of #48.

soenkegissel commented 1 year ago

I am facing the same issue with 2.5.0 y5.k as name results of using proguard, which is in fact:

com.suddenh4x.ratingdialog.dialog.DialogOptions -> y5.k:

image