Installation and Setup


Gradle Installation

The simplest way to use the Android Buy SDK in your project is to add the following dependency to your build.gradle file:

compile 'com.shopify.mobilebuysdk:buy:2.0.0'

Manual Addition of Library

If you would prefer to download the .aar file and add it to your project manually, follow these steps:

  1. Download the latest release.
  2. Unzip the Mobile Buy SDK in a known location.
  3. In Android Studio, from the menu select (File | New | New Module | Import .JAR or .AAR package).
  4. Browse to the location where you unzipped the SDK, and select the aar file to import it. A new module will be created.
  5. From the Android Studio menu select (File | Project Structure).
  6. Select your app module, and select the dependencies tab and use the + button to add a new Module dependency on the Mobile Buy SDK module.

Initialize the SDK

Import the Buy packages


Initialize the client

new BuyClientBuilder()


SHOP_DOMAIN is the url of your store, ie. (mandatory)

API_KEY is the api key for your store (mandatory)

APP_ID is the application id for your shop (mandatory)

APP_NAME is the package name of your application (mandatory)

CUSTOMER_TOKEN existing customer token if required (optional)

CALLBACK_SCHEDULER Rx scheduler that will be used for all API callbacks. If no schedult is provided, Android main thread will be used by default (optional)

INTERCEPTORS custom OkHttp interceptors if required (optional)

PRODUCT_PAGE_SIZE page size used for API calls related to the product requests (optional)

RETRY_MAX_COUNT, RETRY_DELAY_MS, RETRY_BACKOFF_MULTIPLIER request retry configuration parameters used to retry api requests on network errors (socket timeout, unknown host, etc.). Network retry is disabled by default (optional)

CONNECTION_TIMEOUT_MS, READ_WRITE_TIMEOUT_MS configuration parameters for OkHttp connections. The default connection timeout is 30 seconds, and the default 60 sec will be used as default values (optional).