8000 chore: fix to support android-12+ (#400) · optimizely/android-sdk@7575bad · GitHub
[go: up one dir, main page]

Skip to content

Commit 7575bad

Browse files
authored
chore: fix to support android-12+ (#400)
Fix for android 12+ support (app crashes with PendingIntent flag requirement when built with targetSdkVersion=31) - upgrade dependency "androidx.work:work-runtime" to 2.7.1 - add "android:exported" to test-app activities - upgrade compileSDKVersion/targetSDKVersion to 32
1 parent 97168d1 commit 7575bad

File tree

9 files changed

+49
-32
lines changed

9 files changed

+49
-32
lines changed

android-sdk/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ dependencies {
7272
testImplementation "org.powermock:powermock-mockito-release-full:$powermock_ver"
7373
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"
7474

75-
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
76-
// Set this dependency to use JUnit 4 rules
77-
androidTestImplementation "androidx.test:rules:$androidx_test"
78-
// Set this dependency to build and run Espresso tests
75+
androidTestImplementation "androidx.work:work-testing:$work_runtime"
76+
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
7977
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
78+
// Set this dependency to use JUnit 4 rules
79+
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
80+
androidTestImplementation "androidx.test:core:$androidx_test_core"
81+
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"
82+
8083
androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
8184
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
8285
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"

build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,23 @@ ext {
6060
compile_sdk_version = 32
6161
build_tools_version = "30.0.3"
6262
min_sdk_version = 14
63-
target_sdk_version = 29
63+
target_sdk_version = 32
6464
java_core_ver = "3.10.2"
6565
android_logger_ver = "1.3.6"
6666
jacksonversion= "2.11.2"
67-
annotations_ver = "1.0.0"
67+
annotations_ver = "1.2.0"
6868
junit_ver = "4.12"
6969
mockito_ver = "1.10.19"
7070
powermock_ver = "1.6.4"
7171
support_test_runner_ver = "0.5"
7272
dexmaker_ver = "1.4"
73-
espresso_ver = "3.1.0"
74-
gson_ver = "2.8.6"
73+
gson_ver = "2.8.9"
7574
group_id = "com.optimizely.ab"
76-
androidx_test = "1.1.1"
77-
work_runtime = "2.5.0"
75+
work_runtime = "2.7.1"
76+
androidx_test_junit = "1.1.3"
77+
androidx_test_core = "1.4.0"
78+
androidx_test_rules = "1.4.0"
79+
espresso_ver = "3.4.0"
7880
}
7981

8082
task clean(type: Delete) {

datafile-handler/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ dependencies {
5858
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"
5959

6060
androidTestImplementation "androidx.work:work-testing:$work_runtime"
61-
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
62-
// Set this dependency to use JUnit 4 rules
63-
androidTestImplementation "androidx.test:rules:$androidx_test"
64-
// Set this dependency to build and run Espresso tests
61+
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
6562
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
63+
// Set this dependency to use JUnit 4 rules
64+
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
65+
androidTestImplementation "androidx.test:core:$androidx_test_core"
66+
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"
6667

6768
androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
6869
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"

event-handler/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ dependencies {
6262
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"
6363

6464
androidTestImplementation "androidx.work:work-testing:$work_runtime"
65-
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
66-
// Set this dependency to use JUnit 4 rules
67-
androidTestImplementation "androidx.test:rules:$androidx_test"
68-
// Set this dependency to build and run Espresso tests
65+
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
6966
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
67+
// Set this dependency to use JUnit 4 rules
68+
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
69+
androidTestImplementation "androidx.test:core:$androidx_test_core"
70+
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"
71+
7072
androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
7173
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
7274
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"

shared/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ dependencies {
6262
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"
6363

6464
androidTestImplementation "androidx.work:work-testing:$work_runtime"
65-
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
66-
// Set this dependency to use JUnit 4 rules
67-
androidTestImplementation "androidx.test:rules:$androidx_test"
68-
// Set this dependency to build and run Espresso tests
65+
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
6966
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
67+
// Set this dependency to use JUnit 4 rules
68+
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
69+
androidTestImplementation "androidx.test:core:$androidx_test_core"
70+
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"
71+
7072
androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
7173
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
7274
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"

shared/src/main/java/com/optimizely/ab/android/shared/ServiceScheduler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ public PendingIntent getPendingIntent(Intent intent) {
252252
}
253253

254254
private PendingIntent getPendingIntent(Intent intent, int flag) {
255-
return PendingIntent.getService(context, 0, intent, flag);
255+
// Android 31+ requires FLAG_IMMUTABLE explicitly
256+
return PendingIntent.getService(context, 0, intent, flag | PendingIntent.FLAG_IMMUTABLE);
256257
}
257258
}
258259

test-app/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ dependencies {
6868
// testImplementation 'com.optimizely.ab:android-sdk:1.0.0'
6969
testImplementation project(':android-sdk')
7070

71-
androidTestImplementation('androidx.test.ext:junit:1.1.1')
72-
//androidTestimplementation "androidx.annotation:annotation:$annotations_ver"
73-
// Set this dependency to use JUnit 4 rules
74-
androidTestImplementation "androidx.test:rules:$androidx_test"
75-
// Set this dependency to build and run Espresso tests
71+
androidTestImplementation "androidx.work:work-testing:$work_runtime"
72+
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
7673
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
74+
// Set this dependency to use JUnit 4 rules
75+
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
76+
androidTestImplementation "androidx.test:core:$androidx_test_core"
77+
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"
78+
7779
androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
7880
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
7981
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"

test-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
<activity
4242
android:name=".SplashScreenActivity"
43+
android:exported="true"
4344
android:theme="@style/SplashTheme">
4445
<intent-filter>
4546
<action android:name="android.intent.action.MAIN" />

user-profile/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ dependencies {
5757
testImplementation "org.mockito:mockito-core:$mockito_ver"
5858
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"
5959

60-
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
61-
// Set this dependency to use JUnit 4 rules
62-
androidTestImplementation "androidx.test:rules:$androidx_test"
63-
// Set this dependency to build and run Espresso tests
60+
androidTestImplementation "androidx.work:work-testing:$work_runtime"
61+
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
6462
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
63+
// Set this dependency to use JUnit 4 rules
64+
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
65+
androidTestImplementation "androidx.test:core:$androidx_test_core"
66+
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"
67+
6568
androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
6669
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
6770
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"

0 commit comments

Comments
 (0)
0