Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pvegh opened this issue Aug 16, 2023 · 9 comments · Fixed by #2599
Closed

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

pvegh opened this issue Aug 16, 2023 · 9 comments · Fixed by #2599
Labels
Missing repro Platform: Android This issue is specific to Android

Comments

@pvegh
Copy link
Contributor

pvegh commented Aug 16, 2023

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

@github-actions github-actions bot added Platform: Android This issue is specific to Android Missing repro labels Aug 16, 2023
@github-actions
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@pvegh
Copy link
Contributor Author

pvegh commented Aug 17, 2023

Can't do a repro sorry, I'm not into the RN game that much. Just reporting a problem here as well as I can with a possible fix

@pvegh
Copy link
Contributor Author

pvegh commented Aug 21, 2023

Can you please take a look at this? I know there's no repro here but it should be straightforward anyway

@pvegh pvegh changed the title Android: Add buildConfig = true to buildFeatures Add AGP8 support by adding buildConfig = true to buildFeatures Aug 30, 2023
@pvegh
Copy link
Contributor Author

pvegh commented Aug 30, 2023

RN Thread about this: react-native-community/discussions-and-proposals#671

@pvegh
Copy link
Contributor Author

pvegh commented Sep 21, 2023

In my opinion it doesn't need a repro, it's a build simple feature with full description what is missing.
Also I'm not an RN person, I just need the android part to behave well.

@pvegh
Copy link
Contributor Author

pvegh commented Sep 21, 2023

Created a PR, probably need some help since I don't usually do this. #2599

m-bert pushed a commit that referenced this issue Sep 27, 2023
## Description
Add support for AGP8 by adding the buildConfig Flag indicating that this
library uses custom buildconfig fields and needs it's BuildConfig class
generated.
Fixes
#2571

## Test plan

Tested that build works correctly
@pvegh
Copy link
Contributor Author

pvegh commented Oct 11, 2023

Would a patch version with this be possible?

@j-piasecki
Copy link
Member

Yes 😃

@NitinMittal08
Copy link

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':firebase_auth'.

com.android.builder.errors.EvalIssueException: 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

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 6s
Error: Gradle task assembleDebug failed with exit code 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro Platform: Android This issue is specific to Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants