react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

Error with namespace not specified

Open SpaceSimon opened this issue 1 year ago • 6 comments

Description

When trying to run on Android, I have the following error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-iap'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
     
     android {
         namespace 'com.example.namespace'
     }
     
     If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

I am not suprised as declaring the namespace in build.gradle is mandatory from RN 0.72. I am surprised, however, that RNIAP still hasn't made this change, and no one is complaining about it. Do you all use patch-package or fork RNIAP?

Environment:

  • react-native-iap: 13.0.0
  • react-native: 0.72.17
  • Platforms (iOS, Android, emulator, simulator, device): Android

SpaceSimon avatar Jul 16 '25 13:07 SpaceSimon

I've just hit this issue while updating our target SDK to 35 which is mandatory starting August 30. I see this library is still using gradle 7.4.2 so that's why they didn't have to update it yet. I'm going to patch it for now and wait to see if it gets updated 😄

Jmaguerre avatar Jul 16 '25 22:07 Jmaguerre

Thanks for reporting this!

@Jmaguerre You're absolutely right — starting from RN 0.72 and AGP 8.0+, declaring namespace is mandatory. The react-native-iap package hasn’t been updated recently since we’ve shifted development over to [expo-iap](https://github.com/hyochan/expo-iap), which fully supports the new namespace format and modern Android Gradle Plugin.

If you're still using react-native-iap, you can either:

Let me know if you'd like help migrating — happy to assist!

hyochan avatar Jul 18 '25 18:07 hyochan

Thanks for the reply @hyochan. I'll leave it patched for now and soon work on migrating to expo-iap since we already have a bunch of expo libraries in use.

Jmaguerre avatar Jul 21 '25 13:07 Jmaguerre

Thanks for the answer. Do we need to use Expo in order to use the expo-iap?

SpaceSimon avatar Jul 22 '25 08:07 SpaceSimon

Thanks for the answer. Do we need to use Expo in order to use the expo-iap?

In a react-native-cli project, you can install and use expo-modules-core without Expo.

hyochan avatar Jul 22 '25 08:07 hyochan

Closes since this may be resolved in v14.+

hyochan avatar Sep 30 '25 03:09 hyochan