From 891cc69e2e5027897ed1c23d4a35e51eefa593d5 Mon Sep 17 00:00:00 2001 From: Andrey Mischenko Date: Wed, 23 Aug 2023 11:30:33 +0800 Subject: [PATCH] Make project compatible with Gradle 8.x and Android Gradle Plugin 8.x Those changes required if you want too use project as included build for an app which already uses AGP 8. So it allows to debug or experiment with Amplitude SDK as part of your own project - Update Kotlin 1.9.0 and AGP 8.1.0, Gradle 8.2.1 - Removed fat-aar because it's not compatible with AGP 8 (see https://github.com/kezong/fat-aar-android/issues/409), so no dependencies packaging into single AAR anymore, it affects publishing, but doesn't affect if repo used as included build - Fix incompatibility with AGP 8 DSL: added namepaces, enabled required buildFeatures --- android/build.gradle | 15 ++++++++------- build.gradle | 5 ++--- common-android/build.gradle | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- samples/java-android-app/build.gradle | 2 ++ samples/kotlin-android-app/build.gradle | 2 ++ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index ae2344d7..07a3b90e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,6 @@ plugins { id 'com.android.library' id 'kotlin-android' - id 'com.kezong.fat-aar' } ext { @@ -17,6 +16,8 @@ version = PUBLISH_VERSION android { compileSdk 31 + buildFeatures.buildConfig = true + namespace = "com.amplitude.android" defaultConfig { multiDexEnabled true @@ -52,12 +53,12 @@ android { } dependencies { - embed project(':common') - embed project(':common-jvm') - embed project(':common-android') - embed project(':core') - embed project(':event-bridge') - embed project(':id') + implementation project(':common') + implementation project(':common-jvm') + implementation project(':common-android') + implementation project(':core') + implementation project(':event-bridge') + implementation project(':id') implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' implementation 'com.amplitude:analytics-connector:1.0.0' diff --git a/build.gradle b/build.gradle index adf51f03..ca86037e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = "1.5.10" + ext.kotlin_version = "1.9.0" ext.dokka_version = '1.6.10' repositories { maven { url "https://plugins.gradle.org/m2/" } @@ -8,13 +8,12 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:8.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:10.2.1" classpath "io.github.gradle-nexus:publish-plugin:1.1.0" classpath "de.mannodermaus.gradle.plugins:android-junit5:1.8.2.1" - classpath 'com.github.kezong:fat-aar:1.3.8' } } diff --git a/common-android/build.gradle b/common-android/build.gradle index 4866b442..e61c0016 100644 --- a/common-android/build.gradle +++ b/common-android/build.gradle @@ -5,6 +5,7 @@ plugins { } android { + namespace = "com.amplitude.common.android" compileSdk 31 defaultConfig { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 69a97150..84a0b92f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/java-android-app/build.gradle b/samples/java-android-app/build.gradle index 80857de5..05f1479b 100644 --- a/samples/java-android-app/build.gradle +++ b/samples/java-android-app/build.gradle @@ -7,7 +7,9 @@ ext { } android { + namespace = "com.amplitude.android.sample" compileSdk 31 + buildFeatures.buildConfig = true defaultConfig { applicationId "com.amplitude.android.sample" diff --git a/samples/kotlin-android-app/build.gradle b/samples/kotlin-android-app/build.gradle index 9465c774..81a7e323 100644 --- a/samples/kotlin-android-app/build.gradle +++ b/samples/kotlin-android-app/build.gradle @@ -8,7 +8,9 @@ ext { } android { + namespace = "com.amplitude.android.sample" compileSdk 31 + buildFeatures.buildConfig = true defaultConfig { applicationId "com.amplitude.android.sample"