Office Hours — Today, July 2

Tuesday, June 30

Jul 2
7:20 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:25 PM
marekdef
has entered the room
Mark M.
hello, maredef!
how can I help you today?
marekdef
Hi Mark
I have my custom keyboard and a non-editable EditText ...
Is custom view and it seems we need some standard behavior(s)
one is autoSizeTextType
other is blinking cursor
so I wrote a TextWatcher
that measures text
and if is too big
7:30 PM
marekdef
1. modifies content.textScaleX
(content is EditText)
or 2. modifies textSize so it will fit
it works fine
until rotation
the view has Id
so it restores fine
I see the text in LayoutInspector
what happens is that autoscaler is calculating available space
and for rotation is 0
something like content.length
I am adding this textwatcher in a constructor of custom view
Mark M.
your saved instance state will not yet be applied by the time your constructor is called
7:35 PM
marekdef
yes I think it happens later
avaialble space is calculated in textwatcher
so is fired after someones sets the text on this new instance
Mark M.
you may need to override your custom view's onRestoreInstanceState(), chain to the superclass, and then update your text scale at that point (as you should have the text by then)
marekdef
I think it would be to early
content.width is zero apparently
and since textwatcher is called, someone is saving
*some is restoring state
7:40 PM
marekdef
so. the problem is not that the text is empty or something
Mark M.
then perhaps use ViewTreeObserver.OnGlobalLayoutListener to find out when the custom view has been laid out, and at that point both register your TextWatcher and handle any text that you have at the time
because once the view has been laid out, you should have its size to use for your text-length analysis
marekdef
ok will try it out
7:50 PM
marekdef
seems to work!
Mark M.
great!
marekdef
seem the token is still mine :)
recently we released multiple apk
one for api level 16-21 and 22+
this 22+ was already in a market
so I just added the apk for old devices
and i am not sure if is related
7:55 PM
marekdef
but go receiving and error like this
android.os.BadParcelableException
I don't see the message
is only Android 10
Parcel.java:3059
I am using androidxref for source
it does not have android 10 yet
Mark M.
except that line 3059 is blank
marekdef
thx
Mark M.
since device manufacturers change Android, line numbers do not always line up with official AOSP sources
I try to go more by method names from the stack trace, as those usually are consistent
marekdef
Samsung, Nokia, OnePlus
android.os.Parcel.readParcelableCreator
if (creator == null) {
only this throws this Bad...
8:00 PM
Mark M.
what is the error message on the exception?
marekdef
I dont' see it
Mark M.
that's a problem
where are you getting the stack trace from?
marekdef
google play
console, Android Vitals
Mark M.
ah, OK, I and my consulting clients have always used something else, so I do not have direct experience with the one in the Play Console
but without that message, it will be difficult to determine what is going wrong
do you have any custom Parcelable classes?
marekdef
yes @Parcelize
quite a lot I think
Mark M.
are you putting any of those as extras on an Intent being wrapped in a PendingIntent?
such as for a notification, or for AlarmManager?
marekdef
yes notification
Mark M.
that is risky
marekdef
btw the stacktrace does not contain anhything from our aopp
app
8:05 PM
Mark M.
you may want to consider the "convert the Parcelable to a byte[]" approach that I mention at the end of that blog post
marekdef
ok will read that
Mark M.
in that Android 10 source, this problem would result in a BadParcelableException (among all those other cases)
marekdef
the thing is
the app is pretty long on the market
this never happen before
and the recent release was re-release
Mark M.
perhaps Android 10 is unpacking the Parcel in scenarios where it was not doing it before
this is just one area where I know that we can get this exception in seemingly-safe code
I have more on this problem in *The Busy Coder's Guide*: https://wares.commonsware.com/app/internal/book...
marekdef
ok thanks for pointers
Mark M.
I had to apply this for my current customer's project, for this problem, earlier this year
so, it might not be the source of your crash, but it is worth trying
marekdef
will just post a stacktrace
View paste (6 more lines)
android.os.BadParcelableException: 
  at android.os.Parcel.readParcelableCreator (Parcel.java:3059)
  at android.os.Parcel.readParcelable (Parcel.java:2981)
  at android.os.Parcel.readValue (Parcel.java:2883)
  at android.os.Parcel.readArrayMapInternal (Parcel.java:3261)
  at android.os.BaseBundle.initializeFromParcelLocked (BaseBundle.java:292)
  at android.os.BaseBundle.unparcel (BaseBundle.java:236)
  at android.os.BaseBundle.size (BaseBundle.java:355)
  at android.app.servertransaction.LaunchActivityItem.hashCode (LaunchActivityItem.java:208)
  at java.util.AbstractList.hashCode (AbstractList.java:541)
  at java.util.Objects.hashCode (Objects.java:98)
  at android.app.servertransaction.ClientTransaction.hashCode (ClientTransaction.java:241)
  at android.app.servertransaction.TransactionExecutorHelper.tId (TransactionExecutorHelper.java:266)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:86)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2147)
...
8:10 PM
marekdef
maybe it gives more clue
if not I am happy with the links
will have to digest it
Mark M.
unpacking a Bundle just for hashCode() seems excessive, but, I did not write this :-)
but this code should be running in your process, and the PendingIntent problem that I cited is a case where the crash really is in another process and triggers a crash in our own process through some IPC mechanism
marekdef
ok thanks
Mark M.
LaunchActivityItem is tied into launching an activity (not surprising)
so, I would be worried a bit more about Intent extras for this case
but I do not know why you are not getting the detailed error message for the exception
8:15 PM
Mark M.
and that is really what you need to find out what is going on
marekdef
I am not sure either
I think play console don't gather messages
none of the exceptions have them
Mark M.
that sucks
marekdef
ok another thing
Mark M.
longer-term, you might want to consider using something else for crash logging (Crashlytics, your own hosted backend using ACRA as the collector, etc.)
marekdef
yes would like to have crashlytics
ACRA would be an option too
one thing about designer/developer cooperation
we support lot of devices
16+
the designs are usually for tall slim phones
8:20 PM
marekdef
the question is what would be the best way to tackle that
Mark M.
tackle what, exactly?
marekdef
excuse me
tackle design for smaller phones
1. expect each screen also for smaller devices
convince designers to have small phone by default
or expect sample screens for smaller phones
Mark M.
ideally, designers design around the smallest screen that your firm is willing to support -- usually it is easier to expand a small design than it is to shrink a large design
since that did not happen here, the simplest thing to do is to get a smaller device, test the app, take screenshots of where things are not fitting, and ask for updated designs that can take the smaller screen into account
some of your screens will be fine, and others will require some adjustment
8:25 PM
marekdef
ok
what I do is I create emulator that has size exactly as in zeplin/figma
mdpi
then I can compare screenshot and export
Mark M.
I have it a bit easier, in that I have *lots* of hardware, acquired over the years
somebody might grumble that the emulator is not "real", so I try to test with hardware where I can
marekdef
ok thanks for the chat
Mark M.
happy to help!
marekdef
good night
8:30 PM
marekdef
I am watching Jupiter and Saturn btw
one at a time ofc
Mark M.
enjoy the planet-watching!
and, have a pleasant evening!
marekdef
has left the room
Mark M.
turned off guest access

Tuesday, June 30

 

Office Hours

People in this transcript

  • marekdef
  • Mark Murphy