dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.81k stars 641 forks source link

Build error cause of buildconfig flag missing for AGP8+ #2779

Open gramosukaj opened 3 months ago

gramosukaj commented 3 months ago

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description

When upgrading to compile and target version to API 34 (with minimum gradle 8.1.1), an error occurred during the android build :

A problem occurred configuring project '
'. > 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

Expected Behavior

Successful build like using the API 33.

Environment:

To Reproduce Steps to reproduce the behavior:

Change your compileSdkVersion and targetSdkVersion to 34

Change your gradle version in android/build.gradle like this : classpath("com.android.tools.build:gradle:8.1.1")

And change your android/gradle/wrapper/gradle-wrapper.properties like this : distributionUrl=https://services.gradle.org/distributions/gradle-8.1-all.zip

Then try to build and the error should occur.


The fix , add buildconfig flag for AGP8+:

  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
  if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
      buildFeatures {
          buildConfig = true
      }
  }
mharrison-nzme commented 1 hour ago

Same issue, thanks for a solution @gramosukaj