Code Monkey home page Code Monkey logo

Comments (6)

nuzelac avatar nuzelac commented on May 31, 2024 1

Please disregard, this is happening because I'm using flutter's shared_preferences plugin, which converts Set to List when you read from it. By default that plugin uses its own shared prefs xml but I forked it to read default shared prefs so that's why it interferes with RevenueCat.

from purchases-flutter.

nuzelac avatar nuzelac commented on May 31, 2024 1

Hi @diegocom I'm running a fork of shared_preferences plugin so that I can read default Android prefs.
This migration of Set to List in getAllPrefs method will cause the crash on next launch so I simply ignore this migration when prefix length 0 (e.g. I'm trying to read all prefs, not just Flutter ones).

You can check my commit here:
nuzelac/plugins@ae51d83

from purchases-flutter.

diegocom avatar diegocom commented on May 31, 2024 1

@nuzelac Great, it works! You saved my day

from purchases-flutter.

diegocom avatar diegocom commented on May 31, 2024

@nuzelac Hi, I have the same problem. I need to read the Android default shared preferences and not the flutter ones, but after reading them the app will crash on subsequent launches. How did you solve?

from purchases-flutter.

vegaro avatar vegaro commented on May 31, 2024

Is there anything we can do on our side to prevent this from happening for future developers? I am not sure I completely understand what's going on 😆 @nuzelac @diegocom

from purchases-flutter.

nuzelac avatar nuzelac commented on May 31, 2024

@vegaro Hah, it's a very specific issue, I had to look through my old commits to see how I fixed this. 😀

The thing is, Flutter's shared_preferences plugin doesn't allow you to read any arbitrary prefs from Android, it adds a Flutter specific prefix by default and will only read prefs with the prefix. I think it will also use separate XML, but not certain about that.
I had a Xamarin app that used prefs and wanted to read these back when I migrated my app to Flutter.

If you hack around it (to make this prefix optional) you can read anything but the getter has some internal logic that converts Set to List serialized into String. This will touch RC prefs data and crash your SDK on launch next time.

https://github.com/flutter/plugins/blob/master/packages/shared_preferences/shared_preferences/android/src/main/java/io/flutter/plugins/sharedpreferences/MethodCallHandlerImpl.java#L181-L196

Honestly, I wouldn't expect you to handle this case gracefully since it's not usual behavior 🤔

from purchases-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.