Skip to main content

Step 1: Project Setup & SDK Initialization

This prompt guides LLM to set up Flower SDK dependencies and initialization in an Android project.

Before using: Replace {{SDK_VERSION}} with the actual SDK version provided to your project.

We are integrating the FLOWER SDK into our Android project.

========================================
STEP 1 — Add FLOWER SDK Dependency
========================================

Use AnypointMedia's Maven repository. Google's Maven repository and JitPack are also required,
because part of the SDK's transitive dependencies are resolved from them.

Repository URLs:
https://maven.anypoint.tv/repository/public-release
https://jitpack.io
google() (Google Maven repository)

Support both Kotlin DSL and Groovy DSL.

--------------------------------------------------
If using Kotlin DSL (AGP 8+ preferred in settings.gradle.kts):

dependencyResolutionManagement {
repositories {
google()
maven("https://maven.anypoint.tv/repository/public-release")
maven("https://jitpack.io")
}
}

dependencies {
implementation("flower-sdk:sdk-android-ott:{{SDK_VERSION}}")

// Add ONLY if the project uses FlowerMedia3ExoPlayer.
// Supported androidx.media3 versions: 1.2.1 and above.
// The companion artifact depends on sdk-android-ott, so add both together.
// Pick the artifact whose version exactly matches the app's androidx.media3 version (>= 1.2.1):
// androidx.media3 1.10.1 -> sdk-android-ott-media3-1.10.1
// For androidx.media3 versions below 1.2.1, contact dev-support@anypointmedia.com.
// implementation("flower-sdk:sdk-android-ott-media3-1.10.1:{{SDK_VERSION}}")
}

--------------------------------------------------
If using Groovy DSL:

repositories {
google()
maven { url "https://maven.anypoint.tv/repository/public-release" }
maven { url "https://jitpack.io" }
}

dependencies {
implementation "flower-sdk:sdk-android-ott:{{SDK_VERSION}}"

// Add ONLY if the project uses FlowerMedia3ExoPlayer.
// Supported androidx.media3 versions: 1.2.1 and above.
// The companion artifact depends on sdk-android-ott, so add both together.
// Pick the artifact whose version exactly matches the app's androidx.media3 version (>= 1.2.1):
// androidx.media3 1.10.1 -> sdk-android-ott-media3-1.10.1
// For androidx.media3 versions below 1.2.1, contact dev-support@anypointmedia.com.
// implementation "flower-sdk:sdk-android-ott-media3-1.10.1:{{SDK_VERSION}}"
}

Replace {{SDK_VERSION}} with the appropriate SDK version.

NOTE on the Media3 companion artifact (sdk-android-ott-media3-*):
- The core sdk-android-ott artifact is always required.
- The sdk-android-ott-media3-* artifact is REQUIRED ONLY when using FlowerMedia3ExoPlayer.
It depends on sdk-android-ott, so both artifacts must be added together.
- It is NOT needed for FlowerExoPlayer2 (legacy ExoPlayer) or FlowerBitmovinPlayer.
- Supported androidx.media3 versions: 1.2.1 and above.
- Inspect the project's androidx.media3 version (e.g., in libs.versions.toml or
build.gradle dependencies) and pick the exact same companion artifact version
for any registered version 1.2.1 or above:
androidx.media3 1.10.1 -> flower-sdk:sdk-android-ott-media3-1.10.1
- The companion artifact's version is the FLOWER SDK version ({{SDK_VERSION}}),
not the androidx.media3 version.
- If the project uses an androidx.media3 version not covered above (e.g., below 1.2.1),
instruct the user to contact dev-support@anypointmedia.com instead of guessing
an artifact to add.

NOTE on app requirements (core library desugaring and the Google IMA SDK version):
- The SDK's AAR metadata requires core library desugaring in the app module. Without it
the build fails at checkDebugAarMetadata. Add it if missing:
Kotlin DSL: android { compileOptions { isCoreLibraryDesugaringEnabled = true } }
Groovy DSL: android { compileOptions { coreLibraryDesugaringEnabled true } }
dependencies: coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
- From 2.9.32, the default SDK version is built with Google IMA SDK 3.40.0 and requires
minSdk 24 or higher, compileSdk 35 or higher and Android Gradle Plugin 8.6.0 or higher.
If the app's androidx.core version is lower than 1.10.0, also add
androidx.core:core:1.10.0 (or higher) to the app's dependencies.
- Inspect the project's minSdk, compileSdk and Android Gradle Plugin version. If any of
them is lower and the user does not want to raise it, use the backward-compatible
version built with Google IMA SDK 3.36.0 instead: {{SDK_VERSION}}-IMA_3_36_0
(if {{SDK_VERSION}} already ends with -IMA_3_36_0, use it as is). It requires
minSdk 21 or higher, compileSdk 33 or higher and Android Gradle Plugin 8.0.0 or higher.
Add the same -IMA_3_36_0 suffix to EVERY flower-sdk dependency, including
sdk-android-ott-media3-*. If the suffixed and default versions are mixed, Gradle
resolves the default version.
- If the project cannot meet the backward-compatible version's requirements either,
stop and ask the user to raise them. Do not continue until the user answers.
- Do NOT raise minSdk, compileSdk or the Android Gradle Plugin version without the
user's consent.

========================================
STEP 2 — Configure Cleartext Exception (Conditional)
========================================

We must allow cleartext (HTTP) traffic ONLY for:

prod-reds-device-ad-distributor.ap-northeast-2.elasticbeanstalk.com

----------------------------------------
IMPORTANT LOGIC:
----------------------------------------

1) First, check AndroidManifest.xml:

- If android:usesCleartextTraffic="true" is already set globally:
→ DO NOT create or modify network_security_config.xml.
→ DO NOT add any domain-specific configuration.
→ Leave existing configuration unchanged.

2) If usesCleartextTraffic is NOT globally true:

Then check whether a network security config is already defined:

A) If android:networkSecurityConfig is already present:
- Locate the referenced XML file.
- If a <domain-config> exists:
→ Add the domain inside the existing config
without removing other domains.
- If no suitable <domain-config> exists:
→ Add a new <domain-config cleartextTrafficPermitted="true">
block for this domain.
- Do NOT overwrite unrelated existing security settings.

B) If no networkSecurityConfig is defined:
- Create:
app/src/main/res/xml/network_security_config.xml
- Add:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">
prod-reds-device-ad-distributor.ap-northeast-2.elasticbeanstalk.com
</domain>
</domain-config>
</network-security-config>

- Then update AndroidManifest.xml:
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="false"

========================================
STEP 3 — Initialize and Release SDK
========================================

In your Application class, initialize the SDK in onCreate() and release in onTerminate().

IMPORTANT — Required import:
import tv.anypoint.flower.android.sdk.api.FlowerSdk

Environment modes:
- "local": Local environment, default log level Verbose
- "dev": Development environment, error logs saved to server, default log level Info
- "prod": Production environment, error logs saved to server, default log level Warn

Kotlin:

class YourApplication : Application() {
override fun onCreate() {
super.onCreate()
FlowerSdk.setEnv("local") // Change to "dev" or "prod" as appropriate
FlowerSdk.init(this)
}

override fun onTerminate() {
super.onTerminate()
FlowerSdk.destroy()
}
}

Java:

public class YourApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FlowerSdk.setEnv("local");
FlowerSdk.init(this);
}

@Override
public void onTerminate() {
super.onTerminate();
FlowerSdk.destroy();
}
}

Ensure the Application class is registered in AndroidManifest.xml:

<application android:name=".YourApplication" ...>

----------------------------------------
CONSTRAINTS
----------------------------------------

- Do NOT enable global cleartext traffic unless it is already enabled.
- Do NOT remove existing domain configurations.
- Do NOT overwrite unrelated security rules.
- Keep the implementation minimal and production-safe.
- Maintain compatibility with modern Android Gradle Plugin versions.