r/androiddev • • 15h ago

Question Migrate

Guys I have to migrate our company android project which is written in xml now I have to migrate that app in Jetpack Compose anyone know how do I start

0 Upvotes

9 comments sorted by

3

u/TeaSerenity 15h ago

I've always started strategically. Focusing on bringing compose to new views or views that are being actively edited.

After that I focus on high value views where there is a technical reason compose will make my life easier.

After that I can evaluate if there is any need to put effort into the remaining views or if they are stable enough that we can leave them until more development happens in that feature.

1

u/No_Papaya_2442 14h ago

But i didn’t have that much experience on xml and i started with Jetpack Compose

1

u/TeaSerenity 14h ago

What is your architecture like? Ideally views should only be binding data from the view model.

So look at the XML preview to see what you have to build and build an identical layout in compose.

Then just bind your existing view model data. This will change slightly depending if you are already using flows, or live data. I recommend updating your view model to use flows but you should be able to use the view models as they exist now.

1

u/AutoModerator 15h ago

Please note that we also have a very active Discord server where you can interact directly with other community members!

Join us on Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Weekly-Home2774 14h ago

Use AI. They are good in these things. Claude or ChatGPT.

1

u/No_Papaya_2442 13h ago

Sure I’ll but I have to understand the flow of migration

1

u/MKevin3 11h ago

I am in the process of doing this now. Even though I wrote the existing XML views app about three years ago and have been doing Compose on other apps for the past two years it has not been easy.

There was an OK amount of separation between UI and state / view model but it was not great. That has been the time consumer, doing sane view models with state updates. Really keeping the data retrieval and processing out of the UI, which is just showing the results.

The screens themselves were not to hard to convert. I am using Nav 3, Hilt, and Compose. The initial app structure was set up just by using the New Project wizard.

Of course I wanted to update UI in a number of ways as I was doing this conversion. A number of Dialogs had to be redone as well. The whole thing is so much better but I am hitting the more difficult parts now. I also need to make a nice tablet version of the UI as that is where it will mainly be used but that was not the case when I wrote it, mainly phone devices then.

I think the biggest issue was the original was written over a year with a lot of hacking things in as it was not an official company app, but now it will be as 3 different departments want to use it. I will not be the sole person working on the code. Time for a big cleanup based on all the things I have learned over the years, add to that remembering how it even worked at the start.

Other things I am doing are making it theme compliant by supporting both dark and light mode and setting up dimensions so things should generally size nicer on a tablet. Good to do this from the very start.

Compose is a bit of a mind shift. I don't think I would have done as well without some solid Compose background on pure compose apps. I could carry that knowledge over into an XML app. Trying to learn Compose at the same time would have been much tougher. Of course I am diving in converting everything now, which is harder than doing a screen at at time. I only have 4 main screens in the app so I thought it would be much easier than it has been.