Skip to content

Commit

Permalink
fix(android): add buildFeatures.buildConfig true for AGP8+ compat (#1966
Browse files Browse the repository at this point in the history
)

## 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 for modules that use it

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 should be backwards compatible with older gradle plugins in the exact
same way the previous namespace change was, as it is wrapped in the same
conditional

It is similar to changes I needed to do as react-native-firebase
maintainer -->
invertase/react-native-firebase@b52d0ce

## Test Plan

### What's required for testing (prerequisites)?

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
requires a large amount of transitive dependency changes in CI (see
#1956 !)

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

### What are the steps to reproduce (after prerequisites)?

run the build for android

---------

Co-authored-by: Kacper Kafara <[email protected]>
  • Loading branch information
mikehardy and kkafar authored Nov 16, 2023
1 parent f30efa8 commit 1868f8e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ android {
def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace "com.swmansion.rnscreens"
buildFeatures {
buildConfig true
}
}

// Used to override the NDK path/version on internal CI or by allowing
Expand Down

0 comments on commit 1868f8e

Please sign in to comment.