Office Hours — Today, August 22

Thursday, August 20

Mark M.
has entered the room
Mark M.
turned on guest access
Aug 22
4:00 PM
Urban
has entered the room
Urban
Hi Mark, nice to see you again! Hope you are doing well in these times
Dominic
has entered the room
Mark M.
hello, Urban and Dominic!
Dominic
Hello people!
Urban
Hi Dom!
Mark M.
Urban: you arrived first, so... how can I help you today?
Urban
Thanks Mark - I dont have that many questions to ask
Mark M.
give me your first, then I'll switch to Dominic for a question
Urban
Basically, I am only interested in on thing with which I am hoping you can help me: writing an app with Kotlin that supports both Android and iOS
as far as I know, this can be done by transforming app to library
But my concern is if that would really work?
As iOS probably doesnt have ViewModel and these tpyeos of classes
Sorry to ask you that thing but I havent foound much informatoion on that topic
Mark M.
Kotlin/Multiplatform (KMP) allows for code-sharing between Android and iOS
right now, I'd say that it appears to be mostly for repositories and data sources (thinking in terms of Google's architecture recommendation)
your UI would be platform-specific, so in iOS that's going to be Swift integrating with the Kotlin/Native bits that you get as part of your KMP project setup
4:05 PM
Urban
So basically you are saying that as long as I can transform app to a librabry and get the logic working, I should be able to run it from iOs aswell?
4:05 PM
Urban
(And as you said by using iOS specific UI)
Mark M.
"transform app into library" isn't really how I would describe it
portions of your app would move into a library
basically, it would be those portions that either you are writing in pure Kotlin or rely on KMP-ready libraries
so, you mention ViewModel -- Google's ViewModel is in Java, not Kotlin, so that would not be an available option right now
(I would not be surprised if Google starts converting more of the Jetpack to be in Kotlin, to support KMP, but I don't think ViewModel is there right now)
Urban
So I would need to play a real close attention then to what is Java specific and what Kotlin-specific
Mark M.
right, and that is mostly paying attention to what classes you are importing and where they are coming from
Urban
But is this approach that I am describing a usual way of building app that supports both Android and iOS?
Mark M.
"usual" is probably a bit over-stating it
it is an up-and-coming solution
right now, I think Flutter is the leading cross-platform solution
but that would involve a rewrite of the app into Dart and Flutter
Tad F.
has entered the room
Tad F.
Hi Mark!
Mark M.
(hello, Tad! I'll be with you in a bit!)
Urban
What would you suggest me doing based on this situation - staying with Kotlin and trying it like that?
Tad F.
np
Urban
or doing it with Flutter like you mentioned?
Mark M.
I can't really answer that, as there are lots of elements to that decision
Urban
Okay, thank you for your help. Others need your help too!
Mark M.
OK, I'll be back with you in a while for your next question
Dominic: your turn! how can I help you today?
Dominic
So I would like to ask about minimum api level in play store
4:10 PM
Dominic
I read that starting from november it will be api 29
(for new apps)
Mark M.
that's a targetSdkVersion value
but, yes, I think they are sticking with that date
Dominic
Does it mean that a user having android 5 won't be able to install those new apps from the play store? (sorry, I'm just the beginner)
Mark M.
you are thinking of minSdkVersion
Dominic
ohh
Mark M.
you can have whatever minSdkVersion value that you are willing to support
targetSdkVersion is where the Play Store's requirements come into... play
(pun very much intended)
Dominic
ahh that eases my mind! (nice one haha)
Mark M.
targetSdkVersion will affect how your app runs on the latest version of Android
or, versions, more accurately
so, a targetSdkVersion of 29 puts specific requirements on your app that a value of 28 might avoid, for example
Tad F.
such as?
Mark M.
but it does not affect how older devices behave with your app
for API Level 29, scoped storage is the big one
those are the major things that will change when you raise your targetSdkVersion from 28 to 29
Tad F.
So the inference is that when you target API 29 you must support scoped storage for devices running API 29...correct?
Dominic
thank you! (moing back to background for the time being, doing the exploring android book)
Mark M.
Dominic: OK, I'll will return to you in a bit for your next question
Tad: in the specific case of scoped storage, you can still use android:requestLegacyExternalStorage="true" in <application> in the manifest
they had planned on mandating scoped storage, but they backed off at the last minute
4:15 PM
Mark M.
partly, that was to wait for "raw paths" in Android 11 -- that basically allows READ_EXTERNAL_STORAGE to work almost as it has on older versions
Tad F.
But in general, if a "feature" is released in a new API version, and you specify that version as your target, are you signing up for a contract whereby in your app you must then test for that API level and do things that way for devices running it (and higher)?
Mark M.
for features tied to targetSdkVersion, yes
Tad F.
I'm just wondering if we are setting the stage for a bunch of IF tests in code to know how to handle certain features, depending on what API the target device is running
Mark M.
in some cases, using Jetpack classes will help with that, as they will bake in those IF tests for you
Tad F.
OK - I guess the real concern I have would be to find out what features are mandated. Like the permissions model when it changed.
I have IF statements in my code testing for that to see if I have to at runtime request permission or not
based on API level
Mark M.
for the past few releases, Google has been pretty good about documenting them in pages like the one that I linked to
Tad F.
OK - here is my actual question :)
After our last call, I dove into rxJava
And as a first step, I have replaced my use of AsyncTask, pretty much everywhere (one area left)
I decided to do so, based solely on the use case of:
View paste
user clicks the button

initiate login request

return the results of login request

update UI
Assume that example
between items 2 and 3 there is a config change
I had been doing all sorts of tests to make sure the activity was still valid in step 3
Now I don't have to do that.
If the config happens, I'm disposing the Disposable, then things start again fresh
Errors more easily caught
Is that one of the "simpler" benefits in your mind of that model/
That was the one that made the most sense to me, at least initially
4:20 PM
Mark M.
yes, a reactive solution that is at least sorta lifecycle-aware can help with configuration changes
personally, given RxJava, my preference is to use RxJava for the viewmodel on back, and use LiveData for the "last mile" delivery to the UI
Tad F.
OK - so with this one under my belt, are there any other general areas in 'typical app architecture' that is "the next thing to look for" in your experience that rxJava is particularly suited to help?
Yes I thought about doing that ViewModel switch.
I havnen't yet, because my UIs are very simple
Just a few fields at most each, and I've just used onSaveInstanceState at this point
Rather than a whole new class for each, etc.
Mark M.
in terms of "the next thing to look for", that's a bit difficult to answer in the abstract
the fact that you can assemble fairly complex RxJava chains means that you can combine things in ways that are opaque to callers
so, for example, when you start thinking of caching of Web service results, there are lots of possible ways of accomplishing that
Tad F.
OK - I know sometimes in other architectural switches, there are certain aspects of typical app development really suited to the new approach, I guess i was looking for that kind of direction.
I have another question - but will wait if you want to pop around.
Mark M.
RxJava is basically for anything transactional: it takes a bit but not too long and will wrap up
4:25 PM
Mark M.
so, database I/O, disk I/O, Web service I/O, etc.
Tad F.
Yep, got that part
Mark M.
at that point, it's mostly a question of assembly
for example, you may wind up with a screen that needs results from three different repositories
there, you will probably use something like Single.zip() or Observable.zip() to make those three repository requests and proceed only when you get all three results
Tad F.
Right, vs. nested AsyncTask calls
Mark M.
correct
Tad F.
which get messy really fast
Mark M.
so, you may find that you can detangle some of that if you have it already, or can avoid such tangles in the first place as app development proceeds and you get more complex scenarios
but RxJava is a means to an end, the end being an architecture that you can test and maintain
so long as you are getting that, where and how you apply RxJava depends exclusively on what your app does and needs
let me take questions from the others, and I'll swing back to you in a while
Urban: back to you! do you have another question?
Tad F.
ok!
Urban
I was doing some reading after our talk (I am still stuck with hte same topic) and would like to know what is more preffered way these days: having separate Android and iOS or using multiplatform solution?
Mark M.
that's really a strategic question
is this an app for yourself, or for a business?
4:30 PM
Urban
For myself now but would like to build business around it
4:30 PM
Mark M.
OK
if I had to guess at percentages, and excluding games, I'd venture that 90+% use separate projects
(a lot of game development can be done cross-platform using things like Unity 3D, as I understand it -- it's not really my area)
Urban
So you would suggest me that, if I am thinking going business, it would probably be a better idea to find some1 to do iOS for me or learn it myself?
Mark M.
I have no way of answering that, sorry
I mean, that gets into a whole lot of business strategy stuff
Urban
Okay, I understand. Flutter is probably whole another language from Kotlin, right?
No worries, thank you for your opinion!
Mark M.
Flutter is a framework; Dart is the underlying programming language
the impression that I have gotten from Android developers who have tried Dart is: not as nice as Kotlin, but not bad
a rough analogy is that Flutter = KMP + Jetpack Compose
Urban
Assuming I am doing it with limited time: rewriting this in Dart would probably take me more time then transforming it in Kotlin multiplatoform?
Mark M.
I can't really answer that either
Tad F.
Mark do you have a sense of how much you can actually do in Dart that truly is cross-platform vs. having to call out to platform specific capabilities? I'm thinking of things like Notifications - things that are really differently implemented in iOS vs. Android.
4:35 PM
Mark M.
Tad: sorry, Flutter isn't really my area, so I don't know those details
Urban: if you want iOS, you are going to need to learn something
Urban
I am aware of that and keen of doing that - I am just trying to figure out how to do it in the best way
Mark M.
whether that something is Swift and stuff for a KMP project, or whether that something is Flutter/Dart, will be your choice
Urban
Last question from my side: do you know any good resource how to transform project in KMP?
Because such resource are very scarce
Mark M.
one of the leaders in this space is TouchLab
Tad F.
I'm asking because I watched a Google I/O session on Flutter last year, and one of my takeaways was seeing some code on a slide that was basically IF ioS DO THIS else DO ANDROID that...Made me wonder how much of that you actually have to do...
Urban
Thank you sooooo much for your help! I am finished with my questions now
Mark M.
basically, they have starter kits that can help you get up and going with KMP
Urban
Amazing, this will be suuuuper helpful!
Mark M.
Dominic: back to you! do you have another question?
Dominic
I have simple one, that is in graphic layout editor in android studio
when you hoover over property of something, like "title", layout_width etc
it shows explanation, likely from doccumentation
is there a way to make it last a bit longer
atm most of the time im not able to read it, so I have to google them
4:40 PM
Mark M.
most of those, if you keep your mouse in the tooltip, the tooltip stays open
for this specific feature, I must have those turned off
as I am not getting that documentation
at least not for a simple hover
I usually read the docs in a browser, so I have never played much with in-IDE docs
Dominic
atm I go to "code" and use control j or browser
thanks, good to know some insight too :)
Good night people :) till next time
Mark M.
sorry that I did not have a better answer for that one!
Tad: back to you! do you have another question?
Tad F.
Yeah - I am starting to investigate adding in-app purchasing to my app. What's a good resource to learn the nuts and bolts?
Mark M.
beats me
Tad F.
:)
Mark M.
I generally avoid Google proprietary stuff
and so I have never implemented in-app purchases, even for customers
4:45 PM
Mark M.
OK, at this point, if anyone has any questions, go right ahead! I'll try to field whatever I can in the remaining time
Tad F.
Have you used Hilt?
Mark M.
no, though once it reaches a beta or stable release, I plan to, for the DI chapter in *Elements of Android Jetpack*
Tad F.
I just listened to a 45 minute podcast with the team, sounded really interesting.
I've used Dagger in the past, but it has been a while.
Mark M.
for Kotlin, I'm a Koin fan; for Java, Dagger+Hilt probably is the best option
Tad F.
Are you preferring Kotlin to Java now?
Mark M.
yes
outside of *Elements of Android Jetpack* samples, I very rarely write significant amounts of Java
Tad F.
How long did it take you to become proficient at it once you started?
4:50 PM
Urban
has left the room
Mark M.
I'm not sure what the threshold is for "proficient". I'd say that it took a few months of actively using it to get to the point where I wasn't having daily "WTF?" moments.
Tad F.
That's a good enough definition ;)
Always so many things to learn....a bit overwhelming sometimes!
Thanks Mark, as always. Bye now.
Tad F.
has left the room
4:55 PM
Mark M.
Dominic: if you are still here and have any questions, feel free to ask!
5:00 PM
Dominic
has left the room
Mark M.
turned off guest access

Thursday, August 20

 

Office Hours

People in this transcript

  • Dominic
  • Mark Murphy
  • Tad Frysinger
  • Urban