beeware / briefcase

Tools to support converting a Python project into a standalone native application.
https://briefcase.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
2.47k stars 350 forks source link

Flag optional Toga gradle dependencies. #1845

Closed freakboy3742 closed 3 weeks ago

freakboy3742 commented 1 month ago

With the resolution of beeware/toga#2454, we're now in a position to soften the default Gradle dependencies for a Toga Android project. We can also include the known optional requirement for MapView .

PR Checklist:

rmartin16 commented 1 month ago

Works for me; although, I had to be careful of the version of Toga I was using. Should we consider bumping the Toga requirement in the bootstraps?

freakboy3742 commented 1 month ago

Works for me; although, I had to be careful of the version of Toga I was using. Should we consider bumping the Toga requirement in the bootstraps?

Strictly, that would only be needed for the Android backend; but regardless, I think it's more a case that we need to push out a new Toga release before this is merged. This change won't work until there's a public release that contains beeware/toga#2454; at which point, toga-android~=0.4.0 will resolve correctly, but toga-android~=0.4.0, >=0.4.5 will provide more safety.

mhsmith commented 4 weeks ago

For consistency this should also be done for the com.google.android.material library, which is only used by OptionContainer.

However, wouldn't it be better to include all of Toga's dependencies by default? Before assuming any of them are too large, we should actually measure their effect on the size of the app.

freakboy3742 commented 4 weeks ago

For consistency this should also be done for the com.google.android.material library, which is only used by OptionContainer.

I don't think that's entirely true - we're using Material as a proxy for installing androidx.ConstraintLayout, plus a couple of other dependencies that are fairly fundamental to app operation.

It looks like we could also be using it as a proxy for androidx.appCompat, as that package is a dependency of Material.

However, wouldn't it be better to include all of Toga's dependencies by default? Before assuming any of them are too large, we should actually measure their effect on the size of the app.

I've just built a HelloWorld Android app with 3 different gradle configurations; the AAB sizes for those apps are:

So - there's about a 500kb difference in size including packages that aren't strictly needed. Explicitly including a dependency that is implied has a 100b cost, but that could easily be a quirk of compression.

500kb isn't much, but it also isn't nothing, so my inclination is to keep them optional (and lean into the fact that Material implies AppCompat).

freakboy3742 commented 4 weeks ago

I've also pushed the lower version pin for Toga; this will need to wait until 0.4.5 has landed before CI will pass.

freakboy3742 commented 3 weeks ago

Toga 0.4.5 has been released; I've merged with main, and the tests now pass.