# Configuring your build
Add flavors for testnet and mainnet. Since `productFlavors` cannot start with the word 'test' we recommend:

build.gradle
```groovy
flavorDimensions 'network'
productFlavors {
    // would rather name them "testnet" and "mainnet" but product flavor names cannot start with the word "test"
    zcashtestnet {
        dimension 'network'
        matchingFallbacks = ['zcashtestnet', 'debug']
    }
    zcashmainnet {
        dimension 'network'
        matchingFallbacks = ['zcashmainnet', 'release']
    }
}
```

build.gradle.kts
```kotlin
flavorDimensions.add("network")

productFlavors {
    // would rather name them "testnet" and "mainnet" but product flavor names cannot start with the word "test"
    create("zcashtestnet") {
        dimension = "network"
        matchingFallbacks.addAll(listOf("zcashtestnet", "debug"))
    }

    create("zcashmainnet") {
        dimension = "network"
        matchingFallbacks.addAll(listOf("zcashmainnet", "release"))
    }
}
```

Resources
/src/main/res/values/bools.xml
```
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="zcash_is_testnet">false</bool>
</resources>

```

/src/zcashtestnet/res/values/bools.xml
```
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="zcash_is_testnet">true</bool>
</resources>
```

ZcashNetworkExt.kt
```
/**
 * @return Zcash network determined from resources.
 */
fun ZcashNetwork.Companion.fromResources(context: Context) =
    if (context.resources.getBoolean(R.bool.zcash_is_testnet)) {
        ZcashNetwork.Testnet
    } else {
        ZcashNetwork.Mainnet
    }
```

Add the SDK dependency:

```kotlin
implementation("cash.z.ecc.android:zcash-android-sdk:$LATEST_VERSION")
```

# Using the SDK
Start the [Synchronizer](-synchronizer/README.md)

```kotlin
synchronizer.start(this)
```

Get the wallet's address

```kotlin
synchronizer.getAddress()

// or alternatively

DerivationTool.deriveShieldedAddress(viewingKey)
```

Send funds to another address

```kotlin
synchronizer.sendToAddress(spendingKey, zatoshi, address, memo)
```

The [Synchronizer](-synchronizer/README.md) is the primary entrypoint for the SDK.

1. Start the [Synchronizer](-synchronizer/README.md)
2. Subscribe to wallet data

The [Synchronizer](-synchronizer/README.md) takes care of:

- Connecting to the light wallet server 
- Downloading the latest compact blocks in a privacy-sensitive way
- Scanning and trial decrypting those blocks for shielded transactions related to the wallet
- Processing those related transactions into useful data for the UI
- Sending payments to a full node through [lightwalletd](https://github.com/zcash/lightwalletd)
- Monitoring sent payments for status updates