th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.14k stars 197 forks source link

fix(android): enable buildFeatures.buildConfig for android gradle plugin 8+ #455

Closed mikehardy closed 10 months ago

mikehardy commented 10 months ago

Summary

Upcoming react-native 0.73+ includes android gradle plugin 8+ which needs namespace in build.gradle but also needs buildFeatures.buildConfig enabled as well

It is not sufficient to enable this at the top-level app build.gradle, specific modules that use it (such as those that implement new architecture, it seems) must also enable it at the module level

This change was necessary and is in-use in my work app via patch-package as I work through android-gradle-plugin 8+ issues in prep for react-native 0.73 launching for everyone

It is similar to changes I needed to do as react-native-firebase maintainer --> https://github.com/invertase/react-native-firebase/commit/b52d0ce6723c077190618641ce0f33ced9fd4090

Test Plan

With apologies, you have to alter an app that integrates this module to use android gradle plugin 8, it's difficult to do that in repos I'm proposing these changes in because bumping to android gradle plugin 8 requries a large amount of transitive dependency changes in CI

I have integrated this in an app and tested it, and done similar work as maintainer of react-native-firebase, react-native-netinfo and react-native-device-info, and I'm now pushing these out to the repos

Cheers

jacobp100 commented 10 months ago

Will this break 0.72 and below?

mikehardy commented 10 months ago

Hey @jacobp100 👋 - no it won't break backwards compatibility, AGP7+ started supporting this opt-in though it was not strictly required until AGP8+

AGP6+ does not support it, but it's wrapped in the conditional for backwards compatibility with very old react-native versions that still include AGP <= 6

mikehardy commented 10 months ago

And you can see it built successfully in CI, on 0.72.x

https://github.com/th3rdwave/react-native-safe-area-context/blob/b086b0ef5043836b72c6430cca1641641694fbce/example/package.json#L17