Skip to content

Commit

Permalink
chore: fix to support android-12+ (#400)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jaeopt committed Apr 1, 2022
1 parent 97168d1 commit 7575bad
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 32 deletions.
11 changes: 7 additions & 4 deletions android-sdk/build.gradle
Expand Up @@ -72,11 +72,14 @@ dependencies {
testImplementation "org.powermock:powermock-mockito-release-full:$powermock_ver"
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"

androidTestImplementation "androidx.test.ext:junit:$androidx_test"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test"
// Set this dependency to build and run Espresso tests
androidTestImplementation "androidx.work:work-testing:$work_runtime"
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
androidTestImplementation "androidx.test:core:$androidx_test_core"
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"

androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"
Expand Down
14 changes: 8 additions & 6 deletions build.gradle
Expand Up @@ -60,21 +60,23 @@ ext {
compile_sdk_version = 32
build_tools_version = "30.0.3"
min_sdk_version = 14
target_sdk_version = 29
target_sdk_version = 32
java_core_ver = "3.10.2"
android_logger_ver = "1.3.6"
jacksonversion= "2.11.2"
annotations_ver = "1.0.0"
annotations_ver = "1.2.0"
junit_ver = "4.12"
mockito_ver = "1.10.19"
powermock_ver = "1.6.4"
support_test_runner_ver = "0.5"
dexmaker_ver = "1.4"
espresso_ver = "3.1.0"
gson_ver = "2.8.6"
gson_ver = "2.8.9"
group_id = "com.optimizely.ab"
androidx_test = "1.1.1"
work_runtime = "2.5.0"
work_runtime = "2.7.1"
androidx_test_junit = "1.1.3"
androidx_test_core = "1.4.0"
androidx_test_rules = "1.4.0"
espresso_ver = "3.4.0"
}

task clean(type: Delete) {
Expand Down
9 changes: 5 additions & 4 deletions datafile-handler/build.gradle
Expand Up @@ -58,11 +58,12 @@ dependencies {
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"

androidTestImplementation "androidx.work:work-testing:$work_runtime"
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test"
// Set this dependency to build and run Espresso tests
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
androidTestImplementation "androidx.test:core:$androidx_test_core"
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"

androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
Expand Down
10 changes: 6 additions & 4 deletions event-handler/build.gradle
Expand Up @@ -62,11 +62,13 @@ dependencies {
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"

androidTestImplementation "androidx.work:work-testing:$work_runtime"
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test"
// Set this dependency to build and run Espresso tests
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
androidTestImplementation "androidx.test:core:$androidx_test_core"
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"

androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"
Expand Down
10 changes: 6 additions & 4 deletions shared/build.gradle
Expand Up @@ -62,11 +62,13 @@ dependencies {
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"

androidTestImplementation "androidx.work:work-testing:$work_runtime"
androidTestImplementation "androidx.test.ext:junit:$androidx_test"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test"
// Set this dependency to build and run Espresso tests
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
androidTestImplementation "androidx.test:core:$androidx_test_core"
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"

androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"
Expand Down
Expand Up @@ -252,7 +252,8 @@ public PendingIntent getPendingIntent(Intent intent) {
}

private PendingIntent getPendingIntent(Intent intent, int flag) {
return PendingIntent.getService(context, 0, intent, flag);
// Android 31+ requires FLAG_IMMUTABLE explicitly
return PendingIntent.getService(context, 0, intent, flag | PendingIntent.FLAG_IMMUTABLE);
}
}

Expand Down
12 changes: 7 additions & 5 deletions test-app/build.gradle
Expand Up @@ -68,12 +68,14 @@ dependencies {
// testImplementation 'com.optimizely.ab:android-sdk:1.0.0'
testImplementation project(':android-sdk')

androidTestImplementation('androidx.test.ext:junit:1.1.1')
//androidTestimplementation "androidx.annotation:annotation:$annotations_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test"
// Set this dependency to build and run Espresso tests
androidTestImplementation "androidx.work:work-testing:$work_runtime"
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
androidTestImplementation "androidx.test:core:$androidx_test_core"
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"

androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"
Expand Down
1 change: 1 addition & 0 deletions test-app/src/main/AndroidManifest.xml
Expand Up @@ -40,6 +40,7 @@

<activity
android:name=".SplashScreenActivity"
android:exported="true"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
11 changes: 7 additions & 4 deletions user-profile/build.gradle
Expand Up @@ -57,11 +57,14 @@ dependencies {
testImplementation "org.mockito:mockito-core:$mockito_ver"
testImplementation "com.noveogroup.android:android-logger:$android_logger_ver"

androidTestImplementation "androidx.test.ext:junit:$androidx_test"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test"
// Set this dependency to build and run Espresso tests
androidTestImplementation "androidx.work:work-testing:$work_runtime"
androidTestImplementation "androidx.test.ext:junit:$androidx_test_junit"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_ver"
// Set this dependency to use JUnit 4 rules
androidTestImplementation "androidx.test:rules:$androidx_test_rules"
androidTestImplementation "androidx.test:core:$androidx_test_core"
androidTestImplementation "androidx.test:core-ktx:$androidx_test_core"

androidTestImplementation "org.mockito:mockito-core:$mockito_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$dexmaker_ver"
androidTestImplementation "com.crittercism.dexmaker:dexmaker-dx:$dexmaker_ver"
Expand Down

0 comments on commit 7575bad

Please sign in to comment.