diff --git a/android/build.gradle b/android/build.gradle index a0078e33..521d75d4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,23 +21,36 @@ rootProject.allprojects { apply plugin: 'com.android.library' -android { - // Conditional for compatibility with AGP <4.2. - if (project.android.hasProperty("namespace")) { - namespace 'ly.count.dart.countly_flutter' +// ---- SDK VERSION PARSE ---- +def properties = new File("${rootDir}/../scripts/config/sdk_versions.txt") + +def androidSdkVersion = null + +properties.eachLine { line -> + line = line.trim() + if (line.startsWith("android_sdk_version=")) { + androidSdkVersion = line.split("=")[1].trim() } +} + +println("Using Android Countly SDK version: " + androidSdkVersion) +// ------------------------------------- + +android { + namespace 'ly.count.dart.countly_flutter' compileSdk 35 defaultConfig { minSdkVersion 21 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } + lintOptions { disable 'InvalidPackage' } } dependencies { - implementation 'ly.count.android:sdk:25.4.1' + implementation "ly.count.android:sdk:${androidSdkVersion}" implementation 'com.google.firebase:firebase-messaging:24.0.3' } diff --git a/lib/src/web/countly_flutter_plugin.dart b/lib/src/web/countly_flutter_plugin.dart index 00aa203e..eed52aee 100644 --- a/lib/src/web/countly_flutter_plugin.dart +++ b/lib/src/web/countly_flutter_plugin.dart @@ -338,7 +338,7 @@ class CountlyFlutterPlugin { final head = querySelector('head'); // try this as module - final scriptTag = _createScriptTag(CountlyFlutterPluginConfig.WEB_SDK_URL); + final scriptTag = _createScriptTag(CountlyFlutterPluginConfig.getWebSDKUrl()); head?.children.add(scriptTag); await scriptTag.onLoad.first; diff --git a/lib/src/web/plugin_config.dart b/lib/src/web/plugin_config.dart index 56e36f1b..46b4cb65 100644 --- a/lib/src/web/plugin_config.dart +++ b/lib/src/web/plugin_config.dart @@ -1,5 +1,24 @@ +import 'dart:io'; + class CountlyFlutterPluginConfig { static const String SDK_VERSION_STRING = '25.4.1'; static const String SDK_NAME = 'dart-flutterb-web'; - static const String WEB_SDK_URL = 'https://cdn.jsdelivr.net/npm/countly-sdk-web@25.4.1/lib/countly.min.js'; + static String WEB_SDK_URL = 'https://cdn.jsdelivr.net/npm/countly-sdk-web@{VERSION}/lib/countly.min.js'; + + static String getWebSDKUrl() { + final config = File('scripts/config/sdk_versions.txt').readAsLinesSync(); + + String webVersion = ''; + + for (var line in config) { + line = line.trim(); + if (line.startsWith('web_sdk_version=')) { + webVersion = line.split('=')[1].trim(); + break; + } + } + + final url = WEB_SDK_URL.replaceFirst('{VERSION}', webVersion); + return url; + } } diff --git a/scripts/config/sdk_versions.txt b/scripts/config/sdk_versions.txt new file mode 100644 index 00000000..67ce1d24 --- /dev/null +++ b/scripts/config/sdk_versions.txt @@ -0,0 +1,3 @@ +android_sdk_version=25.4.6 +ios_sdk_version=25.4.7 +web_sdk_version=25.4.1