Skip to content

fix(android): add buildConfig = true, to fix build error on AGP 9 - #1065

Draft
wperkins-micron wants to merge 1 commit into
react-native-datetimepicker:masterfrom
wperkins-micron:master
Draft

wperkins-micron wants to merge 1 commit into
react-native-datetimepicker:masterfrom
wperkins-micron:master

Conversation

@wperkins-micron

Copy link
Copy Markdown

Summary

I am currently updating an Android app from React Native 0.77.3 to 0.87.1. I followed the upgrade helper, which also bumps the Gradle version from 8.10.x to 9.4.1. Attempting to build and run the app under AGP 9 causes the build to fail with the following error:

error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
A problem occurred configuring project ':react-native-community_datetimepicker'.
> 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`

This is fixed by adding the following block of code inside the android block in android/build.gradle:

buildFeatures {
        buildConfig = true
    }

See also a similar issue and open pull request for another RN community module:

No AI was used in the creation of this patch or pull request in any way.

Test Plan

What's required for testing (prerequisites)?

React Native 0.87.1, Gradle 9.4.1

What are the steps to reproduce (after prerequisites)?

After making this change, I ran npm run android. The build process now successfully made it past this module, failing later on another module that has this same issue. (I will mark this pull request as Ready once I have gotten the full app to build successfully.)

Compatibility

OS Implemented
iOS (N/A)
Android ✅

This change is only relevant to building on Android.

Checklist

  • I have tested this on a device and a simulator
  • [ N/A ] I added the documentation in README.md
  • [ N/A ] I updated the typed files (TS and Flow)
  • [ N/A ] I added a sample use of the API in the example project (example/App.js)
  • [ N/A ] I have added automated tests, either in JS or e2e tests, as applicable

it's a 3-line fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant