The modifier order IMHO is a powerful thing. Yes, confusing at first, but once it clicks, it clicks forever, and you'll never wanna use anything else ever again. Modifiers are the reason Compose isn't tied to a "box model" like web, because it doesn't even have one! Everything is modifiers all the way down. No margins, because that's just one more layer of padding. Not outline, because that's just a second layer of border. For beginners, I remember one official video by the Android Developers channel that cleared it up for me, but unsure which one it was. In general, modifiers are applied just as you see them. The one at the very bottom is the innermost, while the one at the top is the outermost. Some modifiers like size modifiers can have tricky interactions when multiple ones are applied, but generally speaking you can force and override these from the top.
I have been watching your tutorials since they 1, you are the best android mentor out there on UA-cam. I love Kotlin and jetpack compose ecosystem even tho I work with flutter but still play around with Jetpack compose in my free time, thank you for giving us this free content Phillip!!!
I've mostly been a web developer (with React, etc), but I first learnt the basics of Android development when I was at school, using XML. I found it to have the same kinds of issues as using the HTML DOM directly on the web (needing to manually keep everything in sync, etc), so I wasn't particularly fond of it. But later on I tried Compose, which I fell in love with
The rounded corners thing is so true xD I never worked with XML long enough to even be good at it (was a beginner to coding in general), but so many simple things like that stuck like a damn sore thumb at me, and I thought I was just dumb or something (thanks XML for the self-esteem) Clipping was one of the first things I tried with Compose, didn't even have to read the docs, with how Compose is (mostly) intuitive, it just showed in auto-complete, used it, worked, no issues! I think this is one of the main benefits Compose gets from not being based on XML; It draws its own content, and thus uses a totally different rendering model that makes the essentials stupid easy to achieve.
HOPE PHILIPP READ THIS !!! as a second year collage student I left Android development and started java development, Reason : I am from India and startups here do not prefer native android developement and it is hard to get job by doing only client side native development. Hence I Decided to choose another harder path, the backend development with java and now focused on learning that;;;;
I'm glad I made the effort to learn Kotlin and Jetpack, as it's lead to one of the most enjoyable programming experiences I've had so far. I would like to pursue a career in native android, but I'm not sure if one can do it with Kotlin and Jetpack alone; there's also Flutter and React: Native to consider, and not a lover of pursuing more than one technology at any one time. Come to think of it, when making offscreen bitmaps for custom drawing( made an old pseudo 3D-maze app ) I had this strange thing where I had to scale the bitmap coordinates by a factor of exactly 3 to display properly. While it seems to work one the devices I use for testing, I couldn't understand why. I've found workarounds, but sometimes getting a composable function to recompose can be downright awkward. And animations don't always happen as expected. But I think all the above might just be things that I'm doing wrong rather than issues with Jetpack itself. I certainly wouldn't go back to Java & XML for android dev.
Hey Philipp, it would be amazing if you could do a tutorial on how to render video in jetpack compose, also considering drm protected content, what alternatives exist, etc... Your videos are amazing
1. Bad preview. It is not always displayed even if everything is written correctly and you need to rebuild it every time. 2. Navigation is not intuitive, worse than fragment navigation. 3. Constant recompositions, which makes them difficult to catch. 4. Some elements like ads, videos and others remain on View, which is why you need to use AndroidView. 5. Long screen loading when opening the application. 6. Some things seem impossible to do on it. For example, when there is a Row and you need to display two elements - a TextField and a button, and the button should be as high as the text field and square, you will see that the button is not even in height.
Some responses: 1) True! Preview has always been a huge issue. Thankfully there's some progress on getting hot reload working on desktop, which is pretty fast and preserves state. 2) Which navigation in particular? And in comparison to what? There's many solutions with downsides and upsides to each, so please specify more! 3) Recompositions aren't a bad thing all the time, until they noticeably impact performance. But yeah, optimizing things is harder in Compose. 4) And that's not an issue IMHO. There's libraries abstracting over these, not everything belongs in the core Compose artifacts. And remember, Compose is multiplatform, so some things should naturally be delegated to third-party libraries. In fact, the fact that Compose has such seamless interop with Views/Swing/UIKit is a pro point! But yeah, more official integration of these platform-specific APIs would be nice to see (like video, etc... but things like AdMob are third-party things outside of Compose's control). Another point is that Compose is mainly a UI library; it handles everything UI, but video is usually very tied to platform specifics and codec support (i.e. it's complicated), as well as WebViews which are also tied to the platform (and bundling a full web engine is not practical). 5) This really depends on the device, and debug builds in particular are slow all around. On a low-end device, startup times are fine with Baseline Profiles, comparable to other view-based apps. 6) That's possible! You might wanna learn a bit more about intrinsic measurements, as well as aspect ratio modifier. Generally speaking, _nothing_ is impossible to do UI-wise, and what you describe is super basic. Compose makes tricky and complex UIs easy, let alone this type of thing. (skill issue)
I went back to studying mobile programming with Jetpack Compose. I don't like XML, and the truth is that I feel very comfortable working with the API, and I want to become a professional to work in the area of mobile application development with Compose.
Why is bigger app size not mentioned as a disadvantage? I made a simple 1 activity app with Jetpack Compose, and the app size was around 25MB. But I made another app with at least 15 simple activities plus a few adapters & fragments, and it weighs almost 10MB.
I’ve made apps with compose fully featured under 5 mb compose doesn’t really have that much size with progaurd on .. 25mb is way too much to blame the framework
I like to ask experienced android developers about one thing that was introduced by google that make you think 'that was exactly what I needed'. Like a slap stright in face :D Does compose is answer for this question? Not sure, but I think it still might be.
Jetpack Compose, like every declarative UI framework before it, does a great job of bridging the gap between Developers and Designers. The catch? You need a whole new mindset to keep that bridge from crumbling. Best of luck to all the Android devs stuck with outdated tools and expert beginners on their teams - you’re gonna need it. 😂
@@PhilippLacknerI have used Compose Desktop and I've found that all components are rendered with the swing API. So Compose doesn't actually draw anything natively
@@marcopinedo2368 I'm not sure what your definition of "native" is, but Compose does its own drawing on desktop as well. Just like Android, it creates an AWT window (when you use the `Window` composable), creates a Swing "canvas" (unsure of the actual API's name), and takes over from there. From there on, Compose draws its own pixels through Skiko (Skia wrapper). Just like Android though, it can interop with Swing, so you could use Compose in a Swing app (e.g. see IntelliJ Idea plugins), and vice versa (to use some existing Swing component in a Compose app. Same applies to iOS (creates a UIKit canvas), and web JS/Wasm (creates an HTML element), and draws using Skiko on all non-Android targets. Note that interop isn't yet implemented for web targets yet.
welp..... i was starting to learn android studio and then alt+enter stopped working for importing modules/packages. restarted computer, new project, cleared caches, filly reinstalled software....... now when I hit alt enter it just prompts with "create extension function bla bla" wtf its infuriating I don't want to have to google around for every effing import I do. Anyone else experience this and have a solution?
I think there is no solution to the problem of modifier order. If you want a clearer expression order, you need a certain configuration file, which will be more troublesome.
Hello Sir, I’m an aspiring Android developer working on a multi-module Jetpack Compose stopwatch app. I’m using a foreground service to manage stopwatch logic and display a persistent notification. However, the app gets killed by Android after a few minutes when I put running stopwatch in the background, causing the stopwatch to stop prematurely. Could you please suggest a possible solution to resolve this issue? please help. Please help.
This is a constant issue for services running in foreground for extended periods of time. You will need ask the users to remove battery restrictions, which 50% of them at least won't do. Different settings are required per manufacturer so hold tight, you fell in a rabbit hole.
There's still many core Android apis not supported. Recently i tried to implement an overlay view that will display over other apps, i actually had to use xml to create it.
Compose is a UI library, not meant to replace platform APIs (nor is that even possible). For your use-case, you'll need to setup the overlay with XML, but you can then put a ComposeView inside it and write Compose code for the actual contents. Anywhere you can put views, you can use Compose (e.g. when you use setContent {} in your activity, all that does is set up a ComposeView at the root of your activity, then delegates drawing into it to Compose UI) That's why places where normal Views aren't supported, you can't use Compose UI. Examples are widgets/notifications, where we have Glade instead (built on Compose Runtime for state and recomposition etc..., but isn't the same as the usual Compose UI)
@HoussamElbadissi I actually tried that but it kept throwing weird exceptions and research found out that there's an issue track for it. Apparently I'm not the only one experiencing such hopefully they'll fix it
I couldn't agree more with everything, good and bad. I hate the navigation part of the compose. I am still using routes for navigation, but I will switch to the object based one in the new projects.
Navigation and Compose are two different Jetpack components. You can integrate them, but you can also use one without the other. Navigation is not Compose.
@@vibovitold it doesn't matter most of the people would still use the navigation library thinking that it's part of the compose core. They won't care about "technicality" ps: I think compose navigation should be easier
I have done Android development using Java and XML 2 years ago and I can say that Jetpack Compose could be future but I see only one problem in that like you said about difficulty in finding performance issue,this is the thing which can make Jetpack Compose unusable because most of users don't bear even small amount of performance issue.I think Jetpack Compose will be like React Native or Flutter in future because bugs and performance issues are most important things to consider
Some pains with Jetpack from my experience: 1. Slower than xml based and even flutter 2. Non-transaction navigation. If you click really fast two times there will be two pages pushed into stack
This is the reality for most companies. Even though Kotlin adoption is much better, there will always be some part of the codebase in Java. Majority of people here have never worked with Android (or programming in general) and think every project uses the latest API’s.
@@D3vCansado Totally agree with Compose but Kotlin should be the standard now. most companies in Israel keep the support for old java based features and make the new ones in kotlin.
please when you speak down your speed of your speaking ,because all students at all over the world watch your videos, that have another native language and don't understand your speaking by speed, thank you so much
The modifier order IMHO is a powerful thing.
Yes, confusing at first, but once it clicks, it clicks forever, and you'll never wanna use anything else ever again.
Modifiers are the reason Compose isn't tied to a "box model" like web, because it doesn't even have one! Everything is modifiers all the way down. No margins, because that's just one more layer of padding. Not outline, because that's just a second layer of border.
For beginners, I remember one official video by the Android Developers channel that cleared it up for me, but unsure which one it was.
In general, modifiers are applied just as you see them. The one at the very bottom is the innermost, while the one at the top is the outermost.
Some modifiers like size modifiers can have tricky interactions when multiple ones are applied, but generally speaking you can force and override these from the top.
I have been watching your tutorials since they 1, you are the best android mentor out there on UA-cam.
I love Kotlin and jetpack compose ecosystem even tho I work with flutter but still play around with Jetpack compose in my free time, thank you for giving us this free content Phillip!!!
I've mostly been a web developer (with React, etc), but I first learnt the basics of Android development when I was at school, using XML. I found it to have the same kinds of issues as using the HTML DOM directly on the web (needing to manually keep everything in sync, etc), so I wasn't particularly fond of it. But later on I tried Compose, which I fell in love with
The rounded corners thing is so true xD
I never worked with XML long enough to even be good at it (was a beginner to coding in general), but so many simple things like that stuck like a damn sore thumb at me, and I thought I was just dumb or something (thanks XML for the self-esteem)
Clipping was one of the first things I tried with Compose, didn't even have to read the docs, with how Compose is (mostly) intuitive, it just showed in auto-complete, used it, worked, no issues!
I think this is one of the main benefits Compose gets from not being based on XML; It draws its own content, and thus uses a totally different rendering model that makes the essentials stupid easy to achieve.
can’t believe it’s been 4 years. feels like it was yesterday
what is the shortcut that he uses to move a block of code inside of another block? like in 7:22
I also would like to know ....
ctrl + shift + ⬆/⬇
@@comandantety thank you!
HOPE PHILIPP READ THIS !!!
as a second year collage student I left Android development and started java development,
Reason :
I am from India and startups here do not prefer native android developement and it is hard to get job by doing only client side native development.
Hence I Decided to choose another harder path, the backend development with java and now focused on learning that;;;;
I'm glad I made the effort to learn Kotlin and Jetpack, as it's lead to one of the most enjoyable programming experiences I've had so far. I would like to pursue a career in native android, but I'm not sure if one can do it with Kotlin and Jetpack alone; there's also Flutter and React: Native to consider, and not a lover of pursuing more than one technology at any one time.
Come to think of it, when making offscreen bitmaps for custom drawing( made an old pseudo 3D-maze app ) I had this strange thing where I had to scale the bitmap coordinates by a factor of exactly 3 to display properly. While it seems to work one the devices I use for testing, I couldn't understand why.
I've found workarounds, but sometimes getting a composable function to recompose can be downright awkward. And animations don't always happen as expected.
But I think all the above might just be things that I'm doing wrong rather than issues with Jetpack itself. I certainly wouldn't go back to Java & XML for android dev.
Hey Philipp, it would be amazing if you could do a tutorial on how to render video in jetpack compose, also considering drm protected content, what alternatives exist, etc... Your videos are amazing
1. Bad preview. It is not always displayed even if everything is written correctly and you need to rebuild it every time.
2. Navigation is not intuitive, worse than fragment navigation.
3. Constant recompositions, which makes them difficult to catch.
4. Some elements like ads, videos and others remain on View, which is why you need to use AndroidView.
5. Long screen loading when opening the application.
6. Some things seem impossible to do on it. For example, when there is a Row and you need to display two elements - a TextField and a button, and the button should be as high as the text field and square, you will see that the button is not even in height.
The last one is possible with intrinsic height if I understand the problem correctly
For 6) Set intrinsic height modifier to the parent row and maxheight for the button. It should work as far I remember.
Some responses:
1) True! Preview has always been a huge issue. Thankfully there's some progress on getting hot reload working on desktop, which is pretty fast and preserves state.
2) Which navigation in particular? And in comparison to what? There's many solutions with downsides and upsides to each, so please specify more!
3) Recompositions aren't a bad thing all the time, until they noticeably impact performance. But yeah, optimizing things is harder in Compose.
4) And that's not an issue IMHO. There's libraries abstracting over these, not everything belongs in the core Compose artifacts. And remember, Compose is multiplatform, so some things should naturally be delegated to third-party libraries. In fact, the fact that Compose has such seamless interop with Views/Swing/UIKit is a pro point! But yeah, more official integration of these platform-specific APIs would be nice to see (like video, etc... but things like AdMob are third-party things outside of Compose's control).
Another point is that Compose is mainly a UI library; it handles everything UI, but video is usually very tied to platform specifics and codec support (i.e. it's complicated), as well as WebViews which are also tied to the platform (and bundling a full web engine is not practical).
5) This really depends on the device, and debug builds in particular are slow all around. On a low-end device, startup times are fine with Baseline Profiles, comparable to other view-based apps.
6) That's possible! You might wanna learn a bit more about intrinsic measurements, as well as aspect ratio modifier. Generally speaking, _nothing_ is impossible to do UI-wise, and what you describe is super basic. Compose makes tricky and complex UIs easy, let alone this type of thing. (skill issue)
@@LeelaSlayys I tried to do like you said , I even used conslain layout for compose, but unfortunatelly it doesnt work for me
I went back to studying mobile programming with Jetpack Compose. I don't like XML, and the truth is that I feel very comfortable working with the API, and I want to become a professional to work in the area of mobile application development with Compose.
Why is bigger app size not mentioned as a disadvantage?
I made a simple 1 activity app with Jetpack Compose, and the app size was around 25MB.
But I made another app with at least 15 simple activities plus a few adapters & fragments, and it weighs almost 10MB.
I’ve made apps with compose fully featured under 5 mb compose doesn’t really have that much size with progaurd on .. 25mb is way too much to blame the framework
Heard of proguard?
You may add much more large size libs
you don't know what are you doing
I like to ask experienced android developers about one thing that was introduced by google that make you think 'that was exactly what I needed'. Like a slap stright in face :D
Does compose is answer for this question? Not sure, but I think it still might be.
Jetpack Compose, like every declarative UI framework before it, does a great job of bridging the gap between Developers and Designers. The catch? You need a whole new mindset to keep that bridge from crumbling.
Best of luck to all the Android devs stuck with outdated tools and expert beginners on their teams - you’re gonna need it. 😂
Jetpack Compose is not based on XML not even on a low level.
If you think about that deeply,its not positive point its negative point 😅
Your Compose UI is using a ComposeView under the hood which draws stuff on a canvas
@@PhilippLacknerI have used Compose Desktop and I've found that all components are rendered with the swing API. So Compose doesn't actually draw anything natively
@@PhilippLackner I mean, that's how _any_ UI library gets to draw stuff on Android, whether it's Compose, Flutter, or Unity.
@@marcopinedo2368 I'm not sure what your definition of "native" is, but Compose does its own drawing on desktop as well. Just like Android, it creates an AWT window (when you use the `Window` composable), creates a Swing "canvas" (unsure of the actual API's name), and takes over from there. From there on, Compose draws its own pixels through Skiko (Skia wrapper).
Just like Android though, it can interop with Swing, so you could use Compose in a Swing app (e.g. see IntelliJ Idea plugins), and vice versa (to use some existing Swing component in a Compose app.
Same applies to iOS (creates a UIKit canvas), and web JS/Wasm (creates an HTML element), and draws using Skiko on all non-Android targets.
Note that interop isn't yet implemented for web targets yet.
For new projects, is there any case where the use of XML is a better choice?
15:07
really? Is Jetpack compose based on XML? 😳
I want to buy your course but it's too expensiive in my country
welp..... i was starting to learn android studio and then alt+enter stopped working for importing modules/packages. restarted computer, new project, cleared caches, filly reinstalled software....... now when I hit alt enter it just prompts with "create extension function bla bla" wtf its infuriating
I don't want to have to google around for every effing import I do. Anyone else experience this and have a solution?
Whole android development sucks but i don't know why i love it
I didnt but didnt you just change shortcut ? There selection thing iirc with alt+... That change many shortcut.
May I know your android studio theme😊
Related: JetBrains porting it for iOS, Web and Desktop has been a game changer for my work...
I think there is no solution to the problem of modifier order. If you want a clearer expression order, you need a certain configuration file, which will be more troublesome.
Hello Sir, I’m an aspiring Android developer working on a multi-module Jetpack Compose stopwatch app. I’m using a foreground service to manage stopwatch logic and display a persistent notification. However, the app gets killed by Android after a few minutes when I put running stopwatch in the background, causing the stopwatch to stop prematurely. Could you please suggest a possible solution to resolve this issue? please help. Please help.
This is a constant issue for services running in foreground for extended periods of time. You will need ask the users to remove battery restrictions, which 50% of them at least won't do. Different settings are required per manufacturer so hold tight, you fell in a rabbit hole.
There's still many core Android apis not supported. Recently i tried to implement an overlay view that will display over other apps, i actually had to use xml to create it.
Compose is a UI library, not meant to replace platform APIs (nor is that even possible).
For your use-case, you'll need to setup the overlay with XML, but you can then put a ComposeView inside it and write Compose code for the actual contents. Anywhere you can put views, you can use Compose (e.g. when you use setContent {} in your activity, all that does is set up a ComposeView at the root of your activity, then delegates drawing into it to Compose UI)
That's why places where normal Views aren't supported, you can't use Compose UI. Examples are widgets/notifications, where we have Glade instead (built on Compose Runtime for state and recomposition etc..., but isn't the same as the usual Compose UI)
@HoussamElbadissi I actually tried that but it kept throwing weird exceptions and research found out that there's an issue track for it. Apparently I'm not the only one experiencing such hopefully they'll fix it
Modifiers are like matrix multiplications. Order is from right to left.
Tried to enroll in the masterclass but got a 403 response
Might be a network/country issue, do you have the chance to use a VPN?
@@PhilippLackner Possibly because I'm in Hong Kong. I'll give it a shot with a VPN
@@PhilippLackner That solved it. Thanks for all the good work, buddy, keep it up!
flutter took off so much why is jetpack is so behind ,is it relly worth it
I couldn't agree more with everything, good and bad. I hate the navigation part of the compose. I am still using routes for navigation, but I will switch to the object based one in the new projects.
Navigation and Compose are two different Jetpack components. You can integrate them, but you can also use one without the other. Navigation is not Compose.
@@vibovitold it doesn't matter most of the people would still use the navigation library thinking that it's part of the compose core. They won't care about "technicality"
ps:
I think compose navigation should be easier
I can't do check out on your course. It says 403 forbidden.
Use vpn
i will migrate to compose if tag compose in stackoverflow reach 100k :)
I have done Android development using Java and XML 2 years ago and I can say that Jetpack Compose could be future but I see only one problem in that like you said about difficulty in finding performance issue,this is the thing which can make Jetpack Compose unusable because most of users don't bear even small amount of performance issue.I think Jetpack Compose will be like React Native or Flutter in future because bugs and performance issues are most important things to consider
Animations became easy in Compose.
Entire adapter class concept got killed in Compose
Compose preview is also bad. No hot reload feature yet
@@UmerFarooq-vk9be the preview has massively improved, it's pretty good nowadays
Plz bring discounts for the courses bundles and plz take Indian rupee of euro for Indians
Constraint Layout Visibility GONE is missed out
Some pains with Jetpack from my experience:
1. Slower than xml based and even flutter
2. Non-transaction navigation. If you click really fast two times there will be two pages pushed into stack
Point 2 can be frustrating
It can be handled programmatically but of course it should be handled natively
Bro, I am still using XML and Java 😅
It's time to leave that company lol
custom ROM development? =)
cringey
This is the reality for most companies. Even though Kotlin adoption is much better, there will always be some part of the codebase in Java. Majority of people here have never worked with Android (or programming in general) and think every project uses the latest API’s.
@@D3vCansado Totally agree with Compose but Kotlin should be the standard now.
most companies in Israel keep the support for old java based features and make the new ones in kotlin.
please when you speak down your speed of your speaking ,because all students at all over the world watch your videos, that have another native language and don't understand your speaking by speed, thank you so much
Whole android development sucks but i don't know why i love it
i dont have a problem with side effects. i dont think it's unintuitive
This is literally ReactJs in disguise 😆
Flutter is better still for ui
Fourth
Android is a dead end at least when it comes to Indian job scenario don't waste your time here.
Why ? with your numbers, shouldnt Android dev being searched ?
In India its not about anything, its just about money. If you can throw anything at free or dirt cheap you can get along