Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5012: Remove KitKat support #5630

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ WORKSPACE @oppia/android-app-infrastructure-reviewers
# Proguard configurations for Bazel builds.
/config/proguard/ @oppia/android-dev-workflow-reviewers

# Configuration for KitKat-specific curated builds.
/config/kitkat_main_dex_class_list.txt @oppia/android-dev-workflow-reviewers

# Specific manifest files specifically required for Bazel builds.
/app/src/main/AppAndroidManifest.xml @oppia/android-dev-workflow-reviewers
/app/src/main/DatabindingAdaptersManifest.xml @oppia/android-dev-workflow-reviewers
Expand Down
349 changes: 8 additions & 341 deletions .github/workflows/build_tests.yml

Large diffs are not rendered by default.

79 changes: 3 additions & 76 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ jobs:
max-parallel: 10
matrix: ${{ fromJson(needs.bazel_compute_affected_targets.outputs.matrix) }}
env:
ENABLE_CACHING: false
CACHE_DIRECTORY: ~/.bazel_cache
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -206,57 +205,7 @@ jobs:
echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc
shell: bash

# See explanation in bazel_build_app for how this is installed.
- name: Install git-secret (non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
shell: bash
run: |
cd $HOME
mkdir -p $HOME/gitsecret
git clone https://github.com/sobolevn/git-secret.git git-secret
cd git-secret && make build
PREFIX="$HOME/gitsecret" make install
echo "$HOME/gitsecret" >> $GITHUB_PATH
echo "$HOME/gitsecret/bin" >> $GITHUB_PATH

- name: Decrypt secrets (non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }}
run: |
cd $HOME
# NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout!
echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg
gpg --import ./git_secret_private_key.gpg
cd $GITHUB_WORKSPACE
git secret reveal

# See https://www.cyberciti.biz/faq/unix-for-loop-1-to-10/ for for-loop reference.
- name: Build Oppia Tests (with caching, non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
# Attempt to build 5 times in case there are flaky builds.
# TODO(#3759): Remove this once there are no longer app test build failures.
i=0
# Disable exit-on-first-failure.
set +e
while [ $i -ne 5 ]; do
i=$(( $i+1 ))
echo "Attempt $i/5 to build test targets"
bazel build --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS
done
# Capture the error code of the final command run (which should be a success if there isn't a real build failure).
last_error_code=$?
# Reenable exit-on-first-failure.
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)

- name: Build Oppia Tests (without caching, or on a fork)
if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }}
- name: Build Oppia Tests
env:
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
Expand All @@ -276,30 +225,8 @@ jobs:
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Run Oppia Tests (with caching, non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
# Attempt to build 5 times in case there are flaky builds.
# TODO(#3970): Remove this once there are no longer app test build failures.
i=0
# Disable exit-on-first-failure.
set +e
while [ $i -ne 5 ]; do
i=$(( $i+1 ))
echo "Attempt $i/5 to run test targets"
bazel test --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS
done
# Capture the error code of the final command run (which should be a success if there isn't a real build failure).
last_error_code=$?
# Reenable exit-on-first-failure.
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Run Oppia Tests (without caching, or on a fork)
if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }}

- name: Run Oppia Tests
env:
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
Expand Down
63 changes: 1 addition & 62 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# TODO(#1532): Rename file to 'BUILD' post-Gradle.

load("@dagger//:workspace_defs.bzl", "dagger_rules")
load("//:build_flavors.bzl", "AVAILABLE_FLAVORS", "define_oppia_aab_binary_flavor", "transform_android_manifest")
load("//:version.bzl", "MAJOR_VERSION", "MINOR_VERSION", "OPPIA_DEV_KITKAT_VERSION_CODE", "OPPIA_DEV_VERSION_CODE")

# This is exported here since config/ isn't a Bazel package.
exports_files(["config/kitkat_main_dex_class_list.txt"])
load("//:build_flavors.bzl", "AVAILABLE_FLAVORS", "define_oppia_aab_binary_flavor")

# Corresponds to being accessible to all Oppia targets. This should be used for production APIs &
# modules that may be used both in production targets and in tests.
Expand Down Expand Up @@ -73,63 +69,6 @@ package_group(
)

# TODO(#1640): Move binary manifest to top-level package post-Gradle.
[
transform_android_manifest(
name = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"],
application_relative_qualified_class = ".app.application.dev.DeveloperOppiaApplication",
build_flavor = apk_flavor_metadata["flavor"],
input_file = "//app:src/main/AndroidManifest.xml",
major_version = MAJOR_VERSION,
minor_version = MINOR_VERSION,
output_file = "AndroidManifest_transformed_%s.xml" % apk_flavor_metadata["flavor"],
version_code = apk_flavor_metadata["version_code"],
)
for apk_flavor_metadata in [
{
"flavor": "oppia",
"version_code": OPPIA_DEV_VERSION_CODE,
},
{
"flavor": "oppia_kitkat",
"version_code": OPPIA_DEV_KITKAT_VERSION_CODE,
},
]
]

[
android_binary(
name = apk_flavor_metadata["flavor"],
custom_package = "org.oppia.android",
enable_data_binding = True,
main_dex_list = apk_flavor_metadata.get("main_dex_list"),
manifest = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"],
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "%d" % apk_flavor_metadata["min_sdk_version"],
"targetSdkVersion": "%d" % apk_flavor_metadata["target_sdk_version"],
},
multidex = apk_flavor_metadata["multidex"],
deps = [
"//app/src/main/java/org/oppia/android/app/application/dev:developer_application",
"//config/src/java/org/oppia/android/config:all_languages_config",
],
)
for apk_flavor_metadata in [
{
"flavor": "oppia",
"min_sdk_version": 21,
"multidex": "native",
"target_sdk_version": 34,
},
{
"flavor": "oppia_kitkat",
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
"min_sdk_version": 21,
"multidex": "manual_main_dex",
"target_sdk_version": 34,
},
]
]

# Define all binary flavors that can be built. Note that these are AABs, not APKs, and can be
# be installed on a local device or emulator using a 'bazel run' command like so:
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"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</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"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</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"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</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"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- TODO(#1632): Remove manifest post-Gradle -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.vm">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- TODO(#1632): Remove manifest post-Gradle -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.view.models">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- TODO(#1632): Remove manifest post-Gradle -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.views">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.app.Application
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDexApplication
import androidx.work.Configuration
import androidx.work.WorkManager
Expand Down Expand Up @@ -39,14 +38,6 @@ abstract class AbstractOppiaApplication(
@SuppressLint("ObsoleteSdkInt") // Incorrect warning.
override fun onCreate() {
super.onCreate()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// Ensure vector drawables can be properly loaded on KitKat devices. Note that this can
// introduce memory issues, but it's an easier-to-maintain solution that replacing all image
// binding with custom hook-ins (especially when it comes to databinding which isn't
// configurable in how it loads drawables), or building a custom vector drawable->PNG pipeline
// in Bazel.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
}
// The current WorkManager version doesn't work in SDK 31+, so disable it.
// TODO(#4751): Re-enable WorkManager for S+.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void setProfileLastVisitedText(@NonNull TextView textView, long ti
}

// TODO(#4345): Add test for this method.
/** Binds an AndroidX KitKat-compatible drawable top to the specified text view. */
/** Binds an AndroidX drawable top to the specified text view. */
@BindingAdapter("drawableTopCompat")
public static void setDrawableTopCompat(
@NonNull TextView imageView,
Expand All @@ -56,7 +56,7 @@ public static void setDrawableTopCompat(
);
}

/** Binds an AndroidX KitKat-compatible drawable end to the specified text view. */
/** Binds an AndroidX drawable end to the specified text view. */
@BindingAdapter("drawableEndCompat")
public static void setDrawableEndCompat(
@NonNull TextView imageView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class OsDeprecationNoticeDialogFragmentTest {
.onActionButtonClicked(
DeprecationNoticeActionResponse.Dismiss(
deprecationNoticeType = DeprecationNoticeType.OS_DEPRECATION,
deprecatedVersion = 19,
deprecatedVersion = 21,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.work.WorkInfo
import androidx.work.WorkManager
import androidx.work.impl.utils.SynchronousExecutor
import androidx.work.testing.WorkManagerTestInitHelper
import com.google.common.base.Optional
import com.google.common.truth.Truth.assertThat
import dagger.Component
import dagger.Module
Expand Down Expand Up @@ -310,19 +309,17 @@ class PlatformParameterIntegrationTest {
jsonPrefixNetworkInterceptor: JsonPrefixNetworkInterceptor,
remoteAuthNetworkInterceptor: RemoteAuthNetworkInterceptor,
@BaseUrl baseUrl: String
): Optional<Retrofit> {
): Retrofit {
val client = OkHttpClient.Builder()
.addInterceptor(jsonPrefixNetworkInterceptor)
.addInterceptor(remoteAuthNetworkInterceptor)
.build()

return Optional.of(
Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(MoshiConverterFactory.create())
.client(client)
.build()
)
return Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(MoshiConverterFactory.create())
.client(client)
.build()
}

@Provides
Expand All @@ -332,9 +329,8 @@ class PlatformParameterIntegrationTest {
@Provides
fun provideMockPlatformParameterService(
mockRetrofit: MockRetrofit
): Optional<PlatformParameterService> {
val delegate = mockRetrofit.create(PlatformParameterService::class.java)
return Optional.of(MockPlatformParameterService(delegate))
): PlatformParameterService {
return MockPlatformParameterService(mockRetrofit.create(PlatformParameterService::class.java))
}
}

Expand Down
Loading
Loading