stripe-react-native
stripe-react-native copied to clipboard
Build Issues - RestrictedApi Again - React Native v0.75
Describe the bug When running ./gradlew build
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':stripe_stripe-react-native:lintDebug'.
D:\app\MobileApp\node_modules\@stripe\stripe-react-native\android\src\main\java\com\reactnativestripesdk\CardFieldView.kt:357: Error: CountryCode can only be accessed from within the same library group (referenced groupId=com.stripe from groupId=EscapeSIM_MobileApp) [RestrictedApi] private fun setPostalCodeFilter(countryCode: CountryCode) {
To Reproduce Steps to reproduce the behavior:
- Deleted the node_modules folder
- npm install (Noticed I was on React Native v0.75)
- ./gradlew clean
- ./gradlew build
Expected behavior Build should complete the lint successfully
Desktop (please complete the following information):
- OS: Windows 11
Smartphone (please complete the following information):
- Device: Virtual Android
Additional context
Adding the existing fix of @SuppressLint("RestrictedApi") before the setPostalCodeFilter function resolved this issue.
The next one I had was
D:\App\MobileApp\node_modules\@stripe\stripe-react-native\android\src\main\java\com\reactnativestripesdk\StripeSdkModule.kt:128: Error: ApiVersion.API_VERSION_CODE can only be accessed from within the same library group (referenced groupId=com.stripe from groupId=EscapeSIM_MobileApp) [RestrictedApi]
So naturally I imported import android.annotation.SuppressLint into StripeSdkModule.kt and added @SuppressLint("RestrictedApi") before override fun getConstants():
Only then was my build passing, hoping that I did this correctly? as everything seems to be working now.