Skip to main content
Get your Android app connected to social.plus in just a few steps. This guide covers everything from installation to your first authenticated session.

Requirements

  • Android 5.0 (API 21)+
  • Target SDK 30+
  • Compile SDK 30+
  • JVM target 1.8
  • Kotlin 1.5.10+

Installation

Add the SDK to your project using your preferred repository:
  • Maven Central
  • Jitpack (Deprecated)
Add Maven Central to your project-level build.gradle:
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
}
Add the dependency to your module-level build.gradle:
implementation("co.amity.android:amity-sdk:x.y.z")
Replace x.y.z with the latest version number.
If your minSDKVersion is below 24, there are additional configurations required. In your project build.gradle:
buildscript {
    repositories {
        google()
        gradlePluginPortal()
        ...
    }
    dependencies {
        ...
        classpath 'gradle.plugin.com.github.sgtsilvio.gradle:android-retrofix:0.4.1'
    }
}

Configuration

Managing conflicting file generation

In your app module’s build.gradle, add the following packaging options.
android {
    ...
    packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
}

ProGuard Rules

If using ProGuard, add these rules to your proguard-rules.pro:
-keep class com.ekoapp.ekosdk.** { *; }
-keep interface com.ekoapp.ekosdk.** { *; }
-keep enum com.ekoapp.ekosdk.** { *; }
-keep class com.amity.socialcloud.** { *; }
-keep interface com.amity.socialcloud.** { *; }
-keep enum com.amity.socialcloud.** { *; }
-keep class co.amity.rxupload.** { *; }
If you are using the SDK version below 6.9.0. If you’d like to pass an Amity Serializable Object such as AmityPost, AmityMessage, etc. You will need to add ProGuard rules below:
-keepclassmembers class * implements java.io.Serializable {
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

Log Visibility Configuration

To control log visibility, add the following to your build.gradle:
android {
    defaultConfig {
        resValue 'bool', "IS_HIDDEN_AMITY_LOG", "true"

    }

}

Database Encryption (Optional)

The SDK does not employ database encryption by default. The database file is solely restricted to the application by the operating system, which is generally sufficient for most use cases.
Database encryption serves as an additional layer of security in the event of compromised root access. Important: Enabling database encryption may lead to a performance reduction of up to 15% during database read/write operations.

Encryption Modes

NONE

No Encryption
Default mode with no encryption applied. Best performance.

AUTH

Token Security
Access token storage is encrypted. Recommended for balanced security.

ALL

Full Encryption
All database files are encrypted. Maximum security.
AUTH mode is recommended to introduce extra security with minimal performance compromise. Choose the encryption mode that aligns with your application’s specific requirements.

Implementation

Encryption Key Management

Enabling database encryption requires an encryption key. You must consistently pass the same key to the SDK. If a new key is supplied, the existing database will be erased and regenerated with the new key.
The level of security depends on your key generation and storage method. Follow industry standards for both key storage and generation.
Add the security library dependency:
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
Secure key implementation:
private fun getEncryptionKey(context: Context): String {
    // Use androidx.security:security-crypto to store generated key
    val securedSharedPreferences = EncryptedSharedPreferences.create(
        "amity_encrypted_shared_prefs",
        MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC),
        context,
        EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
        EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
    )

    val cachedKey = securedSharedPreferences.getString("amity_key", null)
    return if (cachedKey != null) {
        cachedKey
    } else {
        // Generate AES 256-bit key
        val keyGen = KeyGenerator.getInstance("AES")
        keyGen.init(256)
        val key = keyGen.generateKey()
        val encodedKey = key.encoded
        val generatedKey = String(Base64.encode(encodedKey, Base64.DEFAULT))
        
        // Store the key securely
        securedSharedPreferences.edit()
            .putString("amity_key", generatedKey)
            .apply()
        
        generatedKey
    }
}
Usage in your Application class:
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        // Get or generate encryption key
        val encryptionKey = getEncryptionKey(this)
        
        // Setup SDK with encryption
        AmityCoreClient.setup(
            context = this,
            apiKey = "your-api-key",
            region = AmityRegion.SG,
            dbEncryption = AmityDBEncryption.AUTH(encryptionKey.toByteArray())
        )
    }
}

Performance Considerations

Performance Impact: Database encryption adds computational overhead. Consider these factors:
  • AUTH mode: ~5-8% performance impact
  • ALL mode: ~10-15% performance impact
  • Battery usage: Slightly increased due to encryption/decryption operations
  • Storage: Minimal impact on storage size

Next Steps

Troubleshooting

Dependency conflicts: Use the latest versions and ensure all Amity dependencies use the same versionProGuard issues: Make sure you’ve added the required ProGuard rulesMinimum SDK version: Ensure your app’s minimum SDK is at least API 21
SDK not initialized: Make sure you call AmityCoreClient.setup() in your Application classAuthentication failures: Verify your API key and region settingsNetwork errors: Check internet permissions and network connectivity
Missing RxJava: The SDK uses RxJava 2&3 - ensure you have the dependency addedThreading issues: Use .subscribeOn(Schedulers.io()) for background operationsMemory leaks: Always dispose of your subscriptions in onDestroy()