Skip to content

Commit 6ce169a

Browse files
authored
Use CT as implementation instead of api (#526)
1 parent 2180e8c commit 6ce169a

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

AndroidSDKCore/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ android {
2020
buildConfigField 'String', 'LEANPLUM_PACKAGE_IDENTIFIER', "\"${packageIdentifier}\""
2121

2222
buildConfigField 'String', 'SDK_VERSION', "\"${LEANPLUM_SDK_VERSION}\""
23+
buildConfigField 'String', 'CT_SDK_VERSION', "\"${CT_SDK_VERSION}\""
2324

2425
def buildNumber = System.getenv('BUILD_NUMBER') ?: '0'
2526
buildConfigField 'String', 'BUILD_NUMBER', "\"${buildNumber}\""
@@ -42,7 +43,7 @@ dependencies {
4243
api "androidx.legacy:legacy-support-v4:1.0.0"
4344
api "androidx.appcompat:appcompat:${APPCOMPAT_LIBRARY_VERSION}"
4445

45-
api "com.clevertap.android:clevertap-android-sdk:4.6.6"
46+
implementation "com.clevertap.android:clevertap-android-sdk:${CT_SDK_VERSION}"
4647
}
4748

4849
task generateJavadoc(type: Javadoc) {

AndroidSDKCore/src/main/java/com/leanplum/Leanplum.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ public static synchronized void start(final Context context, String userId,
565565
static synchronized void start(final Context context, final String userId,
566566
final Map<String, ?> attributes, StartCallback response, final Boolean isBackground) {
567567
try {
568+
MigrationManager.verifyCleverTapVersion();
569+
568570
boolean appIdNotSet = TextUtils.isEmpty(APIConfig.getInstance().appId());
569571
if (appIdNotSet) {
570572
loadApiConfigFromResources();

AndroidSDKCore/src/main/java/com/leanplum/migration/MigrationManager.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
package com.leanplum.migration
2323

2424
import com.leanplum.callbacks.CleverTapInstanceCallback
25+
import com.leanplum.core.BuildConfig
2526
import com.leanplum.internal.*
2627
import com.leanplum.migration.model.MigrationConfig
2728
import com.leanplum.migration.model.MigrationState
@@ -156,4 +157,26 @@ object MigrationManager {
156157
@JvmStatic
157158
fun trackGooglePlayPurchases() = MigrationConfig.trackGooglePlayPurchases
158159

160+
private fun getCleverTapVersion(): String? {
161+
return try {
162+
val clazz = Class.forName("com.clevertap.android.sdk.BuildConfig")
163+
val field = clazz.getField("VERSION_NAME")
164+
field.get(null) as String
165+
} catch (ignored: Throwable) {
166+
null
167+
}
168+
}
169+
170+
@JvmStatic
171+
fun verifyCleverTapVersion() {
172+
val lpVersion = BuildConfig.CT_SDK_VERSION
173+
val clientVersion = getCleverTapVersion()
174+
if (lpVersion != clientVersion) {
175+
Log.e("Your CleverTap SDK dependency version is:\n" +
176+
"com.clevertap.android:clevertap-android-sdk:${clientVersion}\n" +
177+
"but you must use the supported by Leanplum SDK:\n" +
178+
"com.clevertap.android:clevertap-android-sdk:${lpVersion}")
179+
}
180+
}
181+
159182
}

AndroidSDKFcm/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ dependencies {
3737
compileOnly('com.google.firebase:firebase-messaging:[20.3.0,)') {
3838
exclude module: 'support-v4'
3939
}
40+
41+
implementation "com.clevertap.android:clevertap-android-sdk:${CT_SDK_VERSION}"
4042
}
4143

4244
task generateJavadoc(type: Javadoc) {

common-methods.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
ext {
33
COMPILE_SDK_VERSION = 31
44
APPCOMPAT_LIBRARY_VERSION = '1.2.0'
5+
CT_SDK_VERSION = '4.6.6'
56
MIN_SDK_VERSION = 16
67
JAVA_VERSION = JavaVersion.VERSION_1_8
78

0 commit comments

Comments
 (0)