Skip to content

Add AGP8 support by adding buildConfig = true to buildFeatures #2571

@pvegh

Description

@pvegh

Description

Upgrading to Android Gradle Plugin 8.1 and trying not to use the global flag
android.defaults.buildfeatures.buildconfig=true
which leads to slower builds than defining this only in needed modules
I'm getting the error:

* What went wrong:
A problem occurred configuring project ':react-native-gesture-handler'.
> defaultConfig contains custom BuildConfig fields, but the feature is disabled.
  To enable the feature, add the following to your module-level build.gradle:
  `android.buildFeatures.buildConfig true`

Fix: please add the flag

buildFeatures {
        buildConfig = true
    }

Other projects do something like this:

def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
    if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
        namespace "com.horcrux.svg"
    }

to build.gradle for AGP >= 8.1

Steps to reproduce

  1. Upgrade to AGP 8.1
  2. add android.defaults.buildfeatures.buildconfig=true to gradle.properties (done by AGP upgrade wizard in AS)
  3. ./gradlew assDebug

Snack or a link to a repository

none

Gesture Handler version

2.12.1

React Native version

0.72.2

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions