Skip to content

Commit

Permalink
Fix #3981: Update target API to SDK 30 (#4183)
Browse files Browse the repository at this point in the history
* updated targetd sdk to 30

* nit fixes

* updated maven_install with bazel command

* nit fix

* updated bazel target sdk

* updated manifest targetedsdk

* updatedandroid-sdk in actions

* updated bazel test sdk version

* updated build_flavors

* updated okhttp proguard

* nit fix

* updated sdk version for robolectric

* updated robolectric to 4.5

* update robolectric 4.5.1 to fix artifact download

* trying robolectric laatest version and nit fixes

* lint fix

* robolectric back to 4.5

* updated robolectric on workspace

* updated as per review

* nit fixes + logging connection status

* lint fixes

* added required deps to firebase build bazel

* nit fix

* added string res file to utility module

* nit fix

* nit fixes

* lint fix
  • Loading branch information
anandwana001 authored Mar 15, 2022
1 parent 690f2be commit 9749a9b
Show file tree
Hide file tree
Showing 53 changed files with 796 additions and 722 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ runs:
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platform-tools"
shell: bash

- name: Install SDK 28
- name: Install SDK 30
run: |
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-28"
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-30"
shell: bash

- name: Install build tools 29.0.2
Expand Down
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ package_group(
"flavor": "oppia",
"min_sdk_version": 21,
"multidex": "native",
"target_sdk_version": 29,
"target_sdk_version": 30,
},
{
"flavor": "oppia_kitkat",
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
"min_sdk_version": 19,
"multidex": "manual_main_dex",
"target_sdk_version": 29,
"target_sdk_version": 30,
},
]
]
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load("//third_party:versions.bzl", "HTTP_DEPENDENCY_VERSIONS", "get_maven_depend
# TODO(#1542): Sync Android SDK version with the manifest.
android_sdk_repository(
name = "androidsdk",
api_level = 28,
api_level = 30,
build_tools_version = "29.0.2",
)

Expand Down Expand Up @@ -96,8 +96,8 @@ load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES")
# Add support for Robolectric: https://github.com/robolectric/robolectric-bazel
http_archive(
name = "robolectric",
strip_prefix = "robolectric-bazel-4.4",
urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.4.tar.gz"],
strip_prefix = "robolectric-bazel-4.5",
urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.5.tar.gz"],
)

load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
Expand Down
4 changes: 2 additions & 2 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ MIGRATED_TESTS = [
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "19",
"targetSdkVersion": "28",
"targetSdkVersion": "30",
"versionCode": "0",
"versionName": "0.1-alpha",
},
Expand All @@ -922,7 +922,7 @@ MIGRATED_TESTS = [
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "19",
"targetSdkVersion": "28",
"targetSdkVersion": "30",
"versionCode": "0",
"versionName": "0.1-alpha",
},
Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "org.oppia.android"
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand Down Expand Up @@ -156,8 +156,8 @@ dependencies {
'com.github.bumptech.glide:mocks:4.11.0',
'com.google.truth:truth:1.1.3',
'com.google.truth.extensions:truth-liteproto-extension:1.1.3',
'org.robolectric:annotations:4.4',
'org.robolectric:robolectric:4.4',
'org.robolectric:annotations:4.5',
'org.robolectric:robolectric:4.5',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2',
"org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version",
'org.mockito:mockito-core:2.7.22',
Expand All @@ -173,7 +173,7 @@ dependencies {
'com.google.truth:truth:1.1.3',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2',
'org.mockito:mockito-android:2.7.22',
'org.robolectric:annotations:4.4',
'org.robolectric:annotations:4.5',
)
// Adding the testing module directly causes duplicates of the below groups so we need to
// exclude them before adding the testing module to the androidTestImplementation dependencies
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AppAndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.ui">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.databinding.adapters">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingResourcesManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.databinding">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/RecyclerviewAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.recyclerview.adapters">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.vm">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.view.models">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.views">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class AppVersionActivity : InjectableAppCompatActivity() {
appVersionActivityPresenter.handleOnCreate()
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
if (item?.itemId == android.R.id.home) {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
onBackPressed()
}
return super.onOptionsItemSelected(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ class FAQSingleActivity : InjectableAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
val question = intent.getStringExtra(FAQ_SINGLE_ACTIVITY_QUESTION)
val answer = intent.getStringExtra(FAQ_SINGLE_ACTIVITY_ANSWER)
val question = checkNotNull(intent.getStringExtra(FAQ_SINGLE_ACTIVITY_QUESTION)) {
"Expected $FAQ_SINGLE_ACTIVITY_QUESTION to be in intent extras."
}
val answer = checkNotNull(intent.getStringExtra(FAQ_SINGLE_ACTIVITY_ANSWER)) {
"Expected $FAQ_SINGLE_ACTIVITY_ANSWER to be in intent extras."
}
faqSingleActivityPresenter.handleOnCreate(question, answer)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ class AppLanguageActivity : InjectableAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
prefKey = intent.getStringExtra(APP_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY)
prefKey = checkNotNull(intent.getStringExtra(APP_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY)) {
"Expected $APP_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY to be in intent extras."
}
prefSummaryValue = if (savedInstanceState == null) {
intent.getStringExtra(APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY)
checkNotNull(intent.getStringExtra(APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY)) {
"Expected $APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY to be in intent extras."
}
} else {
savedInstanceState.get(SELECTED_LANGUAGE_EXTRA_KEY) as String
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ class AudioLanguageActivity : InjectableAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
prefKey = intent.getStringExtra(AUDIO_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY)
prefKey = checkNotNull(intent.getStringExtra(AUDIO_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY)) {
"Expected $AUDIO_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY to be in intent extras."
}
prefSummaryValue = if (savedInstanceState != null) {
savedInstanceState.get(AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY) as String
} else {
intent.getStringExtra(AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY)
checkNotNull(intent.getStringExtra(AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY)) {
"Expected $AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY to be in intent extras."
}
}
audioLanguageActivityPresenter.handleOnCreate(prefKey, prefSummaryValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ class ReadingTextSizeActivity : InjectableAppCompatActivity() {

@Inject
lateinit var readingTextSizeActivityPresenter: ReadingTextSizeActivityPresenter
private lateinit var prefKey: String
private lateinit var prefSummaryValue: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
prefKey = intent.getStringExtra(KEY_READING_TEXT_SIZE_PREFERENCE_TITLE)
prefSummaryValue = (
val prefSummaryValue = (
if (savedInstanceState != null) {
savedInstanceState.get(KEY_READING_TEXT_SIZE_PREFERENCE_SUMMARY_VALUE)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,19 @@ class ExplorationActivity :
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
internalProfileId = intent.getIntExtra(EXPLORATION_ACTIVITY_PROFILE_ID_ARGUMENT_KEY, -1)
topicId = intent.getStringExtra(EXPLORATION_ACTIVITY_TOPIC_ID_ARGUMENT_KEY)
storyId = intent.getStringExtra(EXPLORATION_ACTIVITY_STORY_ID_ARGUMENT_KEY)
explorationId = intent.getStringExtra(EXPLORATION_ACTIVITY_EXPLORATION_ID_ARGUMENT_KEY)
topicId = checkNotNull(intent.getStringExtra(EXPLORATION_ACTIVITY_TOPIC_ID_ARGUMENT_KEY)) {
"Expected $EXPLORATION_ACTIVITY_TOPIC_ID_ARGUMENT_KEY to be in intent extras."
}
storyId = checkNotNull(intent.getStringExtra(EXPLORATION_ACTIVITY_STORY_ID_ARGUMENT_KEY)) {
"Expected $EXPLORATION_ACTIVITY_STORY_ID_ARGUMENT_KEY to be in intent extras."
}
explorationId = checkNotNull(
intent.getStringExtra(
EXPLORATION_ACTIVITY_EXPLORATION_ID_ARGUMENT_KEY
)
) {
"Expected EXPLORATION_ACTIVITY_EXPLORATION_ID_ARGUMENT_KEY to be in intent extras."
}
backflowScreen = intent.getIntExtra(EXPLORATION_ACTIVITY_BACKFLOW_SCREEN_KEY, -1)
isCheckpointingEnabled =
intent.getBooleanExtra(EXPLORATION_ACTIVITY_IS_CHECKPOINTING_ENABLED_KEY, false)
Expand Down Expand Up @@ -123,7 +133,7 @@ class ExplorationActivity :
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return explorationActivityPresenter.handleOnOptionsItemSelected(item)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class AdminAuthActivityPresenter @Inject constructor(
binding.adminAuthToolbar.setNavigationOnClickListener {
(activity as AdminAuthActivity).finish()
}
val adminPin = activity.intent.getStringExtra(ADMIN_AUTH_ADMIN_PIN_EXTRA_KEY)
val adminPin = checkNotNull(activity.intent.getStringExtra(ADMIN_AUTH_ADMIN_PIN_EXTRA_KEY)) {
"Expected $ADMIN_AUTH_ADMIN_PIN_EXTRA_KEY to be in intent extras."
}
binding.apply {
lifecycleOwner = activity
viewModel = authViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class TestFontScaleConfigurationUtilActivity : InjectableAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)
val readingTextSize = intent.getStringExtra(FONT_SCALE_EXTRA_KEY)
val readingTextSize = checkNotNull(intent.getStringExtra(FONT_SCALE_EXTRA_KEY)) {
"Expected $FONT_SCALE_EXTRA_KEY to be in intent extras."
}
configUtilActivityPresenter.handleOnCreate(readingTextSize)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ class QuestionPlayerActivityPresenter @Inject constructor(
}

private fun startTrainingSessionWithCallback(callback: () -> Unit) {
val skillIds =
activity.intent.getStringArrayListExtra(QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY)
val skillIds = checkNotNull(
activity.intent.getStringArrayListExtra(
QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY
)
) {
"Expected $QUESTION_PLAYER_ACTIVITY_SKILL_ID_LIST_ARGUMENT_KEY to be in intent extras."
}
val startDataProvider =
questionTrainingController.startQuestionTrainingSession(profileId, skillIds)
startDataProvider.toLiveData().observe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RevisionCardActivity :
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return revisionCardActivityPresenter.handleOnOptionsItemSelected(item)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/test/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.test">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="28" />
android:targetSdkVersion="30" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# app/src/test/resources/robolectric.properties
# TODO(#1794): Remove the need for this file & use SDK 29 at the project level.
sdk=28
sdk=30
8 changes: 4 additions & 4 deletions build_flavors.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _FLAVOR_METADATA = {
"dev": {
"manifest": "//app:src/main/AndroidManifest.xml",
"min_sdk_version": 21,
"target_sdk_version": 29,
"target_sdk_version": 30,
"multidex": "native",
"proguard_specs": [], # Developer builds are not optimized.
"production_release": False,
Expand All @@ -54,7 +54,7 @@ _FLAVOR_METADATA = {
"dev_kitkat": {
"manifest": "//app:src/main/AndroidManifest.xml",
"min_sdk_version": 19,
"target_sdk_version": 29,
"target_sdk_version": 30,
"multidex": "manual_main_dex",
"main_dex_list": _MAIN_DEX_LIST_TARGET_KITKAT,
"proguard_specs": [], # Developer builds are not optimized.
Expand All @@ -67,7 +67,7 @@ _FLAVOR_METADATA = {
"alpha": {
"manifest": "//app:src/main/AndroidManifest.xml",
"min_sdk_version": 21,
"target_sdk_version": 29,
"target_sdk_version": 30,
"multidex": "native",
"proguard_specs": _PRODUCTION_PROGUARD_SPECS,
"production_release": True,
Expand All @@ -79,7 +79,7 @@ _FLAVOR_METADATA = {
"alpha_kitkat": {
"manifest": "//app:src/main/AndroidManifest.xml",
"min_sdk_version": 19,
"target_sdk_version": 29,
"target_sdk_version": 30,
"multidex": "manual_main_dex",
"main_dex_list": _MAIN_DEX_LIST_TARGET_KITKAT,
"proguard_specs": [], # TODO(#3886): Re-add Proguard support to alpha_kitkat.
Expand Down
9 changes: 9 additions & 0 deletions config/proguard/okhttp-proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@
-dontwarn okhttp3.Authenticator*, okhttp3.CookieJar*, okhttp3.Dns*
-dontwarn okhttp3.internal.http2.PushObserver*, okhttp3.internal.io.FileSystem*
-dontwarn org.conscrypt.Conscrypt*

# See: https://github.com/square/okhttp/issues/6258#issuecomment-894168816.
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.bouncycastle.provider.BouncyCastleJsseProvider
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.net.ssl.OpenJSSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.config">

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
</manifest>
Loading

0 comments on commit 9749a9b

Please sign in to comment.