Skip to content

Commit fc6a25d

Browse files
feat: Update Android Gradle plugin to 8.1.0 (#575)
1 parent 05f6133 commit fc6a25d

88 files changed

Lines changed: 1199 additions & 1634 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

android-core/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313
exclude 'META-INF/LICENSE'
1414
}
1515
compileOptions {
16-
sourceCompatibility JavaVersion.VERSION_1_8
17-
targetCompatibility JavaVersion.VERSION_1_8
16+
sourceCompatibility JavaVersion.toVersion(JAVA_VERSION)
17+
targetCompatibility JavaVersion.toVersion(JAVA_VERSION)
1818
}
1919

2020
String url = '\"\"'

android-core/proguard.pro

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,33 @@
252252
public static final ** CREATOR;
253253
}
254254

255-
-keepclassmembers class com.mparticle.Rokt {
256-
<init>(...);
257-
void *(...);
258-
void *$default(...);
259-
<fields>;
255+
# Firebase and GMS CloudMessaging
256+
-dontwarn com.google.android.gms.cloudmessaging.**
257+
-dontwarn com.google.firebase.messaging.**
258+
-keep class com.google.firebase.messaging.** { *; }
259+
260+
# Java 9+ StringConcatFactory
261+
-dontwarn java.lang.invoke.StringConcatFactory
262+
-keep class java.lang.invoke.StringConcatFactory { *; }
263+
264+
# Keep lambdas
265+
-keepclassmembers class * {
266+
private static synthetic *** lambda$*(...);
267+
}
268+
# Additional rules to prevent minification errors with Kotlin
269+
-keepattributes *Annotation*, InnerClasses, Signature, EnclosingMethod
270+
-keepclassmembers class kotlin.Metadata {
271+
public <methods>;
272+
}
273+
-keepclassmembers class * {
274+
@kotlin.Metadata <methods>;
275+
}
276+
277+
-keep public class com.mparticle.Rokt {
278+
public <init>(...);
279+
public void *(...);
280+
public void *$default(...);
281+
public <fields>;
260282
}
261283

262284
-keep interface com.mparticle.MpRoktEventCallback { *; }

android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,13 @@ class MParticleTest : BaseCleanStartedEachTest() {
553553
}
554554
}
555555

556-
private fun getSharedPrefsContents(name: String): String =
557-
try {
558-
val prefs = mContext.getSharedPreferences(name, Context.MODE_PRIVATE)
559-
"""
556+
private fun getSharedPrefsContents(name: String): String = try {
557+
val prefs = mContext.getSharedPreferences(name, Context.MODE_PRIVATE)
558+
"""
560559
$name:
561560
${JSONObject(prefs.all).toString(4)}
562-
""".trimIndent()
563-
} catch (e: JSONException) {
564-
"error printing SharedPrefs :/"
565-
}
561+
""".trimIndent()
562+
} catch (e: JSONException) {
563+
"error printing SharedPrefs :/"
564+
}
566565
}

android-core/src/androidTest/kotlin/com.mparticle/UploadEventKotlinTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class UploadEventKotlinTest : BaseCleanStartedEachTest() {
8181
.any {
8282
val eventMessageName = messagesArray.getJSONObject(it).optString("n")
8383
assertNotEquals("Should Not Upload", eventMessageName)
84-
if (eventMessageName == "Should Upload 1" || eventMessageName == "Should Upload 2" ||
84+
if (eventMessageName == "Should Upload 1" ||
85+
eventMessageName == "Should Upload 2" ||
8586
eventMessageName == "Should Upload 3"
8687
) {
8788
numUploadedEvents++

android-core/src/androidTest/kotlin/com.mparticle/identity/IdentityApiOutgoingTest.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
1616
Matcher(mServer.Endpoints().loginUrl).bodyMatch(
1717
object :
1818
IdentityMatcher() {
19-
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
20-
mStartingMpid == identityRequest.previousMpid
19+
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
2120
},
2221
),
2322
)
@@ -31,8 +30,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
3130
Matcher(mServer.Endpoints().loginUrl).bodyMatch(
3231
object :
3332
IdentityMatcher() {
34-
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
35-
mStartingMpid == identityRequest.previousMpid
33+
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
3634
},
3735
),
3836
)
@@ -46,8 +44,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
4644
Matcher(mServer.Endpoints().logoutUrl).bodyMatch(
4745
object :
4846
IdentityMatcher() {
49-
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
50-
mStartingMpid == identityRequest.previousMpid
47+
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
5148
},
5249
),
5350
)
@@ -61,8 +58,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
6158
Matcher(mServer.Endpoints().logoutUrl).bodyMatch(
6259
object :
6360
IdentityMatcher() {
64-
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
65-
mStartingMpid == identityRequest.previousMpid
61+
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
6662
},
6763
),
6864
)
@@ -88,8 +84,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
8884
Matcher(mServer.Endpoints().identifyUrl).bodyMatch(
8985
object :
9086
IdentityMatcher() {
91-
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
92-
mStartingMpid == identityRequest.previousMpid
87+
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
9388
},
9489
),
9590
)

android-core/src/androidTest/kotlin/com.mparticle/identity/MParticleIdentityClientImplTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ class MParticleIdentityClientImplTest : BaseCleanStartedEachTest() {
249249
mparticle: Boolean,
250250
) {
251251
if (connection.url
252-
.toString()
253-
.contains(MParticleIdentityClientImpl.MODIFY_PATH)
252+
.toString()
253+
.contains(MParticleIdentityClientImpl.MODIFY_PATH)
254254
) {
255255
val jsonObject = payload?.let { JSONObject(it) }
256256
val changedIdentities =

android-core/src/androidTest/kotlin/com.mparticle/internal/AppStateManagerInstrumentedTest.kt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,19 @@ class AppStateManagerInstrumentedTest : BaseCleanStartedEachTest() {
109109

110110
@Test
111111
@Throws(InterruptedException::class)
112-
fun testOnApplicationForeground() =
113-
runTest(StandardTestDispatcher()) {
114-
val latch: CountDownLatch = MPLatch(2)
115-
val kitManagerTester = KitManagerTester(mContext, latch)
116-
com.mparticle.AccessUtils.setKitManager(kitManagerTester)
117-
goToBackground()
118-
Assert.assertNull(mAppStateManager?.currentActivity)
119-
Thread.sleep(AppStateManager.ACTIVITY_DELAY + 100)
120-
goToForeground()
121-
Assert.assertNotNull(mAppStateManager?.currentActivity?.get())
122-
latch.await()
123-
Assert.assertTrue(kitManagerTester.onApplicationBackgroundCalled)
124-
Assert.assertTrue(kitManagerTester.onApplicationForegroundCalled)
125-
}
112+
fun testOnApplicationForeground() = runTest(StandardTestDispatcher()) {
113+
val latch: CountDownLatch = MPLatch(2)
114+
val kitManagerTester = KitManagerTester(mContext, latch)
115+
com.mparticle.AccessUtils.setKitManager(kitManagerTester)
116+
goToBackground()
117+
Assert.assertNull(mAppStateManager?.currentActivity)
118+
Thread.sleep(AppStateManager.ACTIVITY_DELAY + 100)
119+
goToForeground()
120+
Assert.assertNotNull(mAppStateManager?.currentActivity?.get())
121+
latch.await()
122+
Assert.assertTrue(kitManagerTester.onApplicationBackgroundCalled)
123+
Assert.assertTrue(kitManagerTester.onApplicationForegroundCalled)
124+
}
126125

127126
internal inner class KitManagerTester(
128127
context: Context?,

android-core/src/androidTest/kotlin/com.mparticle/internal/BatchSessionInfoTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import kotlin.test.assertNotEquals
1313
class BatchSessionInfoTest : BaseCleanStartedEachTest() {
1414
override fun useInMemoryDatabase() = true
1515

16-
override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder =
17-
builder.logLevel(MParticle.LogLevel.INFO)
16+
override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder = builder.logLevel(MParticle.LogLevel.INFO)
1817

1918
/**
2019
* This test is in response to a bug where, when many messages (> 1 batch worth)

android-core/src/androidTest/kotlin/com.mparticle/internal/ConfigStalenessCheckTest.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,11 @@ class ConfigStalenessCheckTest : BaseCleanInstallEachTest() {
222222
assertEquals(config2.toString(), configManager.config)
223223
}
224224

225-
private fun randomJson(size: Int) =
226-
(1..size)
227-
.map { mRandomUtils.getAlphaNumericString(4) to mRandomUtils.getAlphaNumericString(6) }
228-
.fold(JSONObject()) { init, attribute ->
229-
init.apply { put(attribute.first, attribute.second) }
230-
}
225+
private fun randomJson(size: Int) = (1..size)
226+
.map { mRandomUtils.getAlphaNumericString(4) to mRandomUtils.getAlphaNumericString(6) }
227+
.fold(JSONObject()) { init, attribute ->
228+
init.apply { put(attribute.first, attribute.second) }
229+
}
231230

232231
fun <T> T?.assertNotNull(): T {
233232
assertNotNull(this)

android-core/src/androidTest/kotlin/com.mparticle/internal/database/UpgradeVersionTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ class UpgradeVersionTest : BaseTableTest() {
158158
val sqLiteOpenHelperWrapper: SQLiteOpenHelperWrapper =
159159
object : SQLiteOpenHelperWrapper {
160160
override fun onCreate(db: SQLiteDatabase) {
161-
db.execSQL(SessionTableTest.old_CREATE_SESSION_DDL)
162-
db.execSQL(MessageTableTest.old_no_mpid_CREATE_MESSAGES_DDL)
163-
db.execSQL(BreadcrumbTableTest.old_CREATE_BREADCRUMBS_DDL)
164-
db.execSQL(ReportingTableTest.old_CREATE_REPORTING_DDL)
165-
db.execSQL(UserAttributeTableTest.old_CREATE_USER_ATTRIBUTES_DDL)
161+
db.execSQL(SessionTableTest.OLD_CREATE_SESSION_DDL)
162+
db.execSQL(MessageTableTest.OLD_NO_MPID_CREATE_MESSAGES_DDL)
163+
db.execSQL(BreadcrumbTableTest.OLD_CREATE_BREADCRUMBS_DDL)
164+
db.execSQL(ReportingTableTest.OLD_CREATE_REPORTING_DDL)
165+
db.execSQL(UserAttributeTableTest.OLD_CREATE_USER_ATTRIBUTES_DDL)
166166
}
167167

168168
override fun onUpgrade(

0 commit comments

Comments
 (0)