Nami Public Documentation
Sign In
Nami Documentation
Nami Documentation
  • Get Started
    • Overview
      • Key Concepts
      • Data Collection
      • Built for Privacy
    • Evaluating Nami
    • SDKs
      • Apple Native SDK
      • Android Native SDK
      • Amazon Native SDK
      • Roku Native SDK
      • React Native Cross-Platform SDK
      • Flutter Cross-Platform SDK
      • Unity Cross-Platform SDK
      • Release Notes
        • Find Nami SDK Version
    • Quickstart Guide
  • Subscription Management
    • Overview
    • Products
      • Archive Products
      • Sync Products
    • Entitlements
    • Customer Screen
    • Accounts and Login/Logout
    • Advanced Use Cases
      • Upgrades and Downgrades
      • Supported Purchase Change States by Platform
      • Restoring Purchases
      • Working with Consumable IAPs
  • No Code Paywalls
    • Overview
    • Paywall Creator
      • Using the Creator
      • Paywall Layout
      • Components
        • Editing, Deleting, Reordering
        • Hiding Components
        • Video
        • Collapse
      • Editable Properties
        • Focused Styling
        • Safe Area
      • Conditions
        • Notched Devices
        • Product Entitlements
      • Adding Products
      • Repeating Product Group
      • Product Fields
      • Capabilities
        • Featured Styling
        • Selected Styling
        • Custom Brand Fonts
        • Carousel
        • Trial Eligibility
        • Deeplink Button
        • Introductory Offer Eligibility
        • Login Check
        • Product Groups
        • Conditional Product Groups
        • Offer Eligibility and Purchasing
        • Screenreader Text
        • Personalization Tokens
        • Custom Variables
        • Multipage
        • Custom Data Source
        • Advanced Video Features
        • Product Error States
      • ❓FAQs
        • Designing Paywalls in Figma
        • Guide to Building a Paywall from Scratch
      • 🎁Releases
        • Roadmap
    • Paywall Templates
      • Pacific
      • Pacific Premium
      • Trident
      • Starfish
      • Mantis
      • Venice
      • Venice Premium
      • Honest
      • Catalina
      • Oyster
      • Puffin
      • Marina
      • Beluga
      • Driftwood
      • Lagoon
      • Pisces
      • Aquarius
      • Conch
      • Lionfish
      • Moray
      • Tetra
      • Lighthouse
      • Puffin Tablet
    • Managing Paywalls
      • Archiving a Paywall
      • Duplicate a Paywall
    • Paywall Smart Text
    • Pricing Eligibility States
    • Pricing Eligibility by Platform
    • Nami Paywalls in Different Languages
    • Legacy Paywalls
  • Campaigns
    • Placements
      • Create a Placement
      • Deeplink Placements
      • Archiving a Placement
      • Managing Lots of Placements
      • Export Placements
    • Campaigns
      • Campaign Filters
        • Campaign Use Cases
      • Archiving a Campaign
      • Scheduling a Campaign
      • Campaign Conversion Events
      • Managing Lots of Campaigns
      • Campaign Troubleshooting
    • A/B and Multivariate Testing
      • Selecting an A/B test winner
      • A/B Test Allocation
  • Integrations
    • All Integrations
    • Billing Platforms
      • Apple Integration
        • App Store Setup
          • Privacy Details
        • Platform Integration
        • App Store Server Notifications
        • Store Credentials
          • App Store Connect Shared Secret
          • Apple App Store Connect API
          • Apple In App Purchase
        • Add a Product
        • Platform Sync
        • SDK Integration
        • Troubleshooting
        • Testing and Development
          • Apple Testing Environments
          • Setting up Device Sandbox Test Environment
          • Setting up StoreKit config in Xcode
      • Google Integration
        • Google Play Store Setup
        • Platform Integration
        • Service Account
        • Real-time Developer Notifications
        • Add a Product
        • Platform Sync
        • SDK Setup
        • Troubleshooting
          • Supporting Android minSdkVersion 25 or lower
          • Requested product is not available for purchase
          • Unsupported Version of Play Billing
      • Amazon Appstore Integration
        • Create Amazon Android App
        • Platform Integration
        • Shared Key
        • Real-time Event Notifications
        • Add a Product
        • SDK Integration
        • Testing
      • Roku Integration
        • Platform Integration
        • API Key
        • Transaction Notifications
        • Add a Product
        • SDK Integration
      • Web Integration
    • Analytics Tools
      • Adobe Analytics
      • Amplitude
      • Google Analytics
      • mParticle
      • 3rd-Party Analytics
    • Subscription Management
      • Nami Subscription Management
      • Bring your Own Payment Code
    • CDP Integrations
      • Adobe CDP Integration
      • Amplitude CDP Integration
      • Custom CDP Integration
      • Generic CDP Integration
    • Other Integrations
      • Wicket Labs
      • Webhooks
        • Introduction to the Nami ML Event System
        • Event Types
          • Purchase Status Updates
          • Events for Upgrades, Downgrades, and Crossgrades
        • Event Subscriptions
        • Understanding Transferred Events and Accounts
      • API Access
    • Events Feed
  • Analytics
    • Using Charts
    • Paywall Analytics
      • Impressions
      • Paywall Conversion Rate
      • Sessions
      • Active Devices
    • Subscription Analytics
      • Revenue
      • MRR
      • Purchases
      • Trial Starts
  • Nami Account
    • Manage your Apps
      • Find your Nami App Platform ID
      • Setting up Legal Text for your Apps
    • Organization
      • Configuring Organization Security Policies
      • Billing
    • Invite your Team
      • Roles
    • Manage your Account
      • Two-Factor Authentication (2FA)
Powered by GitBook
On this page
  • Add the SDK to your project
  • Configure the SDK
  • Show a paywall
  • Grant access to paid app features
  • Next Steps
  1. Integrations
  2. Billing Platforms
  3. Google Integration

SDK Setup

How to setup the Google Play Store Android Nami SDK

Please make sure you have completed the setup of your app on the Nami Control Center for all these steps to be successful.

Adding Nami to your app has a few steps for a basic app.

  1. Add the SDK to your project

  2. Configure the SDK

  3. Show a paywall in your app

  4. React to a purchase to grant access to paid content or features

We'll run through each of these below.

Add the SDK to your project

Google Play Android Requirements

  • Android SDK minimum version 22

  • SDK builds target Android 13 (API version 33)

  • SDK has been built with Java v8 and Kotlin v1.6.10

Our Android SDK is available via our Maven repository. Add the following code snippet to your project's build.gradle to add the Nami SDK to your project.

allprojects {
    repositories {
        google()
        mavenLocal()
        maven { url "https://packages.namiml.com/NamiSDK/Android/"}
        maven { url 'https://jitpack.io' }
    }
}

Enterprise customers may have a custom Maven repo. Contact Team Nami to learn more and make sure you are referencing the correct repository.

Then in the build.gradle for your app add the following code, replacing the version number with whichever version of the Nami SDK you would like to run.

dependencies {
  implementation "com.namiml:sdk-android:3.1.5" #Replace with most recent Nami sdk version
}

Add compileOptions for Java 8 compatibility in your appbuild.gradle.

android {
  // Configure only for each module that uses Java 8
  // language features (either in its source code or
  // through dependencies).
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  // For Kotlin projects
  kotlinOptions {
    jvmTarget = JavaVersion.VERSION_1_8.toString()
  }
}

Supporting Android SDK minimum version 25

Configure the SDK

Use Android Studio to Get Code Documentation

The Nami SDK was built with Dokka and if you use Android Studio, you'll get helpful code completions and documentation about methods.

We recommend that you configure the Nami SDK as early in your app's launch as possible. This will ensure the SDK is ready to receive and process purchases.

The best spot to do this is in the onCreate() method in your class that creates your Application and inherits from Application(). Here's a full code example.

You'll need to go find your App Platform ID in the Control Center > Integrations > Google Play for this step.

import com.namiml.Nami
import com.namiml.NamiConfiguration
import com.namiml.NamiLogLevel
  
class DemoApplication : Application() {
    
  override fun onCreate() {
    super.onCreate()
    Nami.configure(
      NamiConfiguration.build(this, "YOUR_APP_PLATFORM_ID") {
        LogLevel = NamiLogLevel.INFO.takeIf { BuildConfig.DEBUG } ?: NamiLogLevel.WARN
      }
    )
  }
}
import com.namiml.Nami;
import com.namiml.NamiConfiguration;

import com.namiml.NamiLogLevel;

public class BasicApplication extends Application {
  private static final String NAMI_APP_PLATFORM_ID = "YOUR_APP_PLATFORM_ID";
  
  @Override
  public void onCreate() {
    super.onCreate();
    NamiConfiguration.Builder builder = new NamiConfiguration
      .Builder(this, NAMI_APP_PLATFORM_ID);
      
    if (BuildConfig.DEBUG) {
      builder.logLevel(NamiLogLevel.INFO);
    }

    Nami.configure(builder.build());
  }
}

Nami recommends setting the log level to WARN for apps on the store. INFO may be helpful during development to better understand what is going on. DEBUG level has a lot of information and is likely only helpful to the Nami support team.

Show a paywall

Now that you have the SDK configured, let's show a paywall in your app.

import com.namiml.campaign.NamiCampaignManager
import com.namiml.campaign.LaunchCampaignResult

import android.util.Log
  
const val LOG_TAG = "ExampleApp"
  
class ExampleActivity : AppCompatActivity() {
  
   override fun onCreate(savedInstanceState: Bundle?) {

      NamiCampaignManager.launch(this) { result ->
        when (result) {
            is LaunchCampaignResult.Success -> {
                Log.d(LOG_TAG, "Launch Campaign Success")
            }
            is LaunchCampaignResult.Failure -> {
                Log.d(LOG_TAG, "Launch Campaign Error -> ${result.error}")
            }
        }
      }
   
   	}
  }
}

Grant access to paid app features

Once a user has made a purchase, you'll need to make sure to give them access to the content and features in your app that require a purchase. This is managed on the Nami platform through our entitlement engine.

The first option is to check whether a specific entitlement is active. This is done with the following code.

if (NamiEntitlementManager.isEntitlementActive("premium_access")) {
 	// allow access to premium app features 
}
if (NamiEntitlementManager.isEntitlementActive("premium_access") {
  // allow access to premium app content 
}

Nami also triggers a callback any time there is a change to the state of an entitlement. In the callback the full list of currently active entitlements is provided. You can use this to store the state of whether a user has access to premium features locally in your app.

It is important that any callbacks are created as early in the app launch as possible. We recommend adding the callback handlers in the NamiSetup method in your AppDelegate.cs.

NamiEntitlementManager.registerEntitlementChangeListener { activeEntitlements ->
  // process active entitlements to grant access
  for (val ent in activeEntitlements) {
    val ent_id = ent.referenceId;
    // use the active entitlements reference IDs to grant
    // access to premium app features
  }
}
import com.namiml.entitlement.NamiEntitlementManager
  
NamiEntitlementManager.registerEntitlementChangeListener { activeEntitlements ->
  // process List<NamiEntitlement> to grant correct access
}

That's all the basics to get up and running with Nami for Google Play - Android apps.

Next Steps

🎉 Congrats on having the basics in place!

Now you are ready to go further based upon your use cases:

Last updated 11 months ago

Release notes for the Android SDK is available .

If your app need to support Android SDK minimum version 25, see for two additional steps to enable the Nami SDK to work properly.

This step requires that you have and attached it to a .

here
this doc
designed a paywall
live campaign
Connect the SDK to your Registration Flow & User Accounts