Skip to main content

Android

Instructions for installing the RevenueCat SDK for Android

AIAsk AIChatGPTClaude

This tutorial shows you how to install the RevenueCat SDK in your Android app. By the end, you'll have the SDK added to your project with Gradle, verified with a successful build, and be ready to configure the SDK.

Prerequisites

You need the following before you start:

1. Install the SDK

Release

The SDK is available on Maven Central and installed with Gradle. The purchases dependency supports Google Play by default. The Amazon Appstore and Galaxy Store each need an extra module (see Other stores).

  1. Add the dependencies to your module's build.gradle.kts (or build.gradle):
implementation("com.revenuecat.purchases:purchases:10.15.1")
implementation("com.revenuecat.purchases:purchases-ui:10.15.1")

If your project uses a version catalog (the default for new Android Studio projects), declare the dependencies in gradle/libs.versions.toml and reference them from your module's build.gradle.kts instead:

[versions]
revenuecat = "10.15.1"

[libraries]
revenuecat-purchases = { group = "com.revenuecat.purchases", name = "purchases", version.ref = "revenuecat" }
revenuecat-purchases-ui = { group = "com.revenuecat.purchases", name = "purchases-ui", version.ref = "revenuecat" }
  1. In Android Studio, select File > Sync Project with Gradle Files.

2. Import the SDK

  1. Add the imports you need to any source file that uses the SDK. These are the most common types:
import com.revenuecat.purchases.CustomerInfo
import com.revenuecat.purchases.Offering
import com.revenuecat.purchases.Purchases
import com.revenuecat.purchases.models.Period
import com.revenuecat.purchases.models.Price
import com.revenuecat.purchases.models.StoreProduct
  1. Build your project (Build > Make Project). If the build succeeds with the imports in place, the SDK is installed correctly.

3. Set your Activity's launchMode

Depending on your user's payment method, Google Play may ask them to verify the purchase in another app, such as their banking app. This means they have to background your app during the purchase. If the launchMode of the Activity that triggers purchases is set to anything other than standard or singleTop, backgrounding your app can cancel the purchase.

  1. In your AndroidManifest.xml, set the launchMode of the Activity that triggers purchases to standard or singleTop:
<activity
android:name="com.your.Activity"
android:launchMode="standard" /> <!-- or singleTop -->

For details on the options, see Android's launchMode documentation.

Other stores

The steps above cover Google Play. Building for the Amazon Appstore or the Galaxy Store requires an additional module and configuration.

Amazon Appstore
  1. Add the purchases-store-amazon module alongside the regular purchases dependency. It contains the classes needed to use Amazon In-App Purchasing:
implementation("com.revenuecat.purchases:purchases:10.15.1")
implementation("com.revenuecat.purchases:purchases-store-amazon:10.15.1")
  1. Add Amazon's .pem public key to your project by following Amazon's Appstore SDK configuration guide.

RevenueCat only validates purchases made in production or in Live App Testing. It won't validate purchases made with the Amazon App Tester.

Galaxy Store

Galaxy Store support is available in Android SDK versions 10.7.0 and above, and React Native SDK versions 10.3.0 and above. Support for other hybrid SDKs is coming soon.

  1. Add the purchases-store-galaxy module alongside the regular purchases dependency:
implementation("com.revenuecat.purchases:purchases:10.15.1")
implementation("com.revenuecat.purchases:purchases-store-galaxy:10.15.1")
  1. When you configure the RevenueCat SDK, configure it to use the Galaxy Store with a GalaxyConfiguration object:
Purchases.configure(
// This will configure the Galaxy Store to make production purchases.
GalaxyConfiguration.Builder(applicationContext, "galx_XXXX") // Add your RevenueCat API key here
.build()
)

Once your project is set up, you can use the RevenueCat SDK with the Galaxy Store the same way you would for Google Play, including fetching offerings, displaying paywalls, and making purchases.

Making test purchases: Galaxy Store test purchases require a physical Galaxy device signed in with a Samsung account. The Galaxy Store does not support test purchases in emulators.

To make a test purchase, pass in either GalaxyBillingMode.TEST or GalaxyBillingMode.ALWAYS_FAIL when you call Purchases.configure():

Purchases.configure(
GalaxyConfiguration.Builder(
applicationContext,
"galx_XXXX", // Add your RevenueCat API key here
GalaxyBillingMode.TEST
)
.build()
)

Use GalaxyBillingMode.TEST to make test purchases without creating financial transactions, and GalaxyBillingMode.ALWAYS_FAIL to test failure scenarios. For more information on the Galaxy Store's billing modes, see Samsung's IAP documentation.

Only use GalaxyBillingMode.PRODUCTION when submitting your app for beta or production distribution.

To cancel a test subscription, open the Galaxy Store on your phone, go to your Samsung account, and cancel the subscription. Test subscriptions remain active until their current billing period ends.

Troubleshooting

Proguard

The SDK ships with its own Proguard rules, so you don't need to do anything. If you have issues finding classes in our SDK, add -keep class com.revenuecat.purchases.** { *; } to your Proguard configuration.

AndroidX App Startup

The SDK uses AndroidX App Startup under the hood, so make sure you have not removed the androidx.startup.InitializationProvider completely from your manifest. If you need to remove specific initializers, such as androidx.work.WorkManagerInitializer, set tools:node="merge" on the provider and tools:node="remove" on the meta-data of the initializer you want to remove:

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>

Next steps

You've installed the RevenueCat SDK and verified your project builds.

Was this page helpful?