Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android kotlin version and min SDK fixes #71

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,33 @@ repositories {
}

def kotlin_version = getExtOrDefault("kotlinVersion")
def localProperties = new Properties()
if (rootProject.file("local.properties").canRead()) {
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
}
def reactNativeVersion = localProperties['reactNativeAndroidVersion'] ?: ""


dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-android:0.73.1"
if (reactNativeVersion) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

// For local development of the SDK code, specify the react-android version to use
// So that the SDK can be built and .kt files are linted against a real version of react-native
implementation "com.facebook.react:react-android:$reactNativeVersion"
} else {
// Production build / once embedded in a react-native app,
// the react-native version gets loaded in from the application dependencies.
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

// Klaviyo Android SDK
api "com.github.klaviyo.klaviyo-android-sdk:analytics:2.0.0"
api "com.github.klaviyo.klaviyo-android-sdk:push-fcm:2.0.0"

// We used reflection to enumerate keywords in the Klaviyo Android SDK dynamically
implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.21"
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
# org.gradle.parallel=true
#Tue Dec 19 15:08:27 EST 2023
KlaviyoReactNativeSdk_compileSdkVersion=31
KlaviyoReactNativeSdk_kotlinVersion=1.7.0
KlaviyoReactNativeSdk_kotlinVersion=1.8.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.8 is compatible with 1.9.22 so we can stop here for now

KlaviyoReactNativeSdk_minSdkVersion=23
KlaviyoReactNativeSdk_ndkversion=21.4.7075529
KlaviyoReactNativeSdk_targetSdkVersion=31
Expand Down
6 changes: 6 additions & 0 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## This file must *NOT* be checked into Version Control Systems,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this into VC to make it easier to access, but it is still git ignored so your local changes to this file won't get committed.

## as it contains information specific to your local configuration

## Uncomment for local SDK development so that gradle can locate the
## correct RN version outside the context of an application
#reactNativeAndroidVersion=0.73.1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KlaviyoReactNativeSdkModule internal constructor(private val context: Reac
override fun setProfile(profile: ReadableMap) {
val parsedProfile = Profile()

profile.toHashMap().forEach { (key, value) ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This triggers a warning about min SDK version of 24.

profile.toHashMap().iterator().forEach { (key, value) ->
when (key) {
LOCATION, PROPERTIES ->
(value as? HashMap<*, *>)?.forEach { (key, value) ->
Expand Down
Loading