Skip to content

Commit

Permalink
Merge pull request #3976 from kiwix/Add_Android_14
Browse files Browse the repository at this point in the history
Added support for Android 14
  • Loading branch information
kelson42 authored Aug 16, 2024
2 parents 453c1d3 + 9ecadfd commit 4a9be43
Show file tree
Hide file tree
Showing 78 changed files with 500 additions and 412 deletions.
49 changes: 9 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Automated tests
strategy:
matrix:
api-level: [ 25, 30, 33 ]
api-level: [ 25, 30, 33, 34 ]
fail-fast: true
runs-on: ubuntu-22.04
steps:
Expand All @@ -21,11 +21,11 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 17

- name: Restore Cache
uses: actions/cache@v4
Expand All @@ -43,50 +43,21 @@ jobs:
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.api-level != 33 && 'default' || 'aosp_atd' }}
arch: x86_64
profile: pixel_2
ram-size: 4096M
force-avd-creation: false
sdcard-path-or-size: 2048M
cores: 4
disable-animations: false
heap-size: 512M
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
channel: canary
script: echo "Generated AVD snapshot for caching."

- name: create instrumentation coverage
uses: reactivecircus/android-emulator-runner@v2
env:
GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000"
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.api-level != 33 && 'default' || 'aosp_atd' }}
target: default
arch: x86_64
profile: pixel_2
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
ram-size: 4096M
cores: 4
force-avd-creation: false
sdcard-path-or-size: 2048M
disable-animations: true
heap-size: 512M
channel: canary
emulator-boot-timeout: 1200
script: bash contrib/instrumentation.sh

- name: Test custom app
Expand All @@ -95,17 +66,15 @@ jobs:
GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000"
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.api-level != 33 && 'default' || 'aosp_atd' }}
target: default
arch: x86_64
profile: pixel_2
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
ram-size: 4096M
ram-size: 3072M
cores: 4
force-avd-creation: true
sdcard-path-or-size: 2048M
sdcard-path-or-size: 1024M
disable-animations: true
emulator-boot-timeout: 1200
heap-size: 512M
channel: canary
script: bash contrib/instrumentation-customapps.sh


Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fdroid_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Decrypt files
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Restore Cache
Expand Down Expand Up @@ -55,10 +55,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Restore Cache
Expand Down Expand Up @@ -93,10 +93,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Restore Cache
Expand Down Expand Up @@ -131,10 +131,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Build all configurations
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Retrieve secrets to files
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 17
distribution: temurin

- name: Retrieve secrets to files
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Studio](https://developer.android.com/studio).

If you prefer to build without Android Studio you must first set up
the Android SDK and then run the command: `./gradlew build ` from the
root directory of the project. The project requires `Java 11` to run,
Therefore set the `Gradle JDK` to `Java 11`.
root directory of the project. The project requires `Java 17` to run,
Therefore set the `Gradle JDK` to `Java 17`.

Kiwix Android is a multi-module project, in 99% of scenarios you will
want to build the `app` module in the `debug` configuration. If you
Expand Down
5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ fun generateVersionName() = "${Config.versionMajor}.${Config.versionMinor}.${Con
val apkPrefix get() = System.getenv("TAG") ?: "kiwix"

android {

// Added namespace in response to Gradle 8.0 and above.
// This is now specified in the Gradle configuration instead of declaring
// it directly in the AndroidManifest file.
namespace = "org.kiwix.kiwixmobile"
defaultConfig {
base.archivesName.set(apkPrefix)
resValue("string", "app_name", "Kiwix")
Expand Down
30 changes: 30 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,33 @@
-keepclassmembers class org.kiwix.kiwixmobile.core.entity.MetaLinkNetworkEntity$* {
<init>(...);
}

-keep class javax.xml.stream.** { *; }
-dontwarn javax.xml.stream.Location
-dontwarn javax.xml.stream.XMLEventReader
-dontwarn javax.xml.stream.XMLInputFactory
-dontwarn javax.xml.stream.events.Attribute
-dontwarn javax.xml.stream.events.Characters
-dontwarn javax.xml.stream.events.StartElement
-dontwarn javax.xml.stream.events.XMLEvent

-keep class okhttp3.internal.** { *; }
-dontwarn okhttp3.internal.Version
-dontwarn okhttp3.internal.annotations.EverythingIsNonNull
-dontwarn okhttp3.internal.http.HttpDate
-dontwarn okhttp3.internal.http.UnrepeatableRequestBody

-keep class org.bouncycastle.jsse.** { *; }
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider

-keep class org.conscrypt.** { *; }
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier

-keep class org.openjsse.javax.net.ssl.** { *; }
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
3 changes: 1 addition & 2 deletions app/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.kiwix.kiwixmobile">
xmlns:android="http://schemas.android.com/apk/res/android">

<!-- support for androidx.test.orchestrator clearPackageData for android 33
see more information here https://github.com/kiwix/kiwix-android/issues/3172
Expand Down
7 changes: 4 additions & 3 deletions app/src/androidTest/java/org/kiwix/kiwixmobile/NetworkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.testutils.TestUtils
import org.kiwix.kiwixmobile.utils.KiwixIdlingResource.Companion.getInstance
import java.util.concurrent.TimeUnit
import org.kiwix.kiwixmobile.core.R.string

/**
* Created by mhutti1 on 14/04/17.
Expand Down Expand Up @@ -95,7 +96,7 @@ class NetworkTest {
fun networkTest() {
ActivityScenario.launch(KiwixMainActivity::class.java)
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
clickMenu(TestUtils.getResourceString(R.string.library))
clickMenu(TestUtils.getResourceString(string.library))
TestUtils.allowStoragePermissionsIfNeeded()
Espresso.onData(TestUtils.withContent("wikipedia_ab_all_2017-03"))
.inAdapterView(ViewMatchers.withId(R.id.libraryList))
Expand All @@ -105,7 +106,7 @@ class NetworkTest {
} catch (e: RuntimeException) {
Log.w(NETWORK_TEST_TAG, "failed to perform click action on the view : ${e.localizedMessage} ")
}
clickOn(R.string.local_zims)
clickOn(string.local_zims)
try {
Espresso.onData(CoreMatchers.allOf(ViewMatchers.withId(R.id.zim_swiperefresh)))
refresh(R.id.zim_swiperefresh)
Expand All @@ -124,7 +125,7 @@ class NetworkTest {
.inAdapterView(ViewMatchers.withId(R.id.zimfilelist))
// TODO how can we get a count of the items matching the dataInteraction?
dataInteraction.atPosition(0).perform(ViewActions.click())
clickMenu(R.string.library)
clickMenu(string.library)
val dataInteraction1 = Espresso.onData(TestUtils.withContent("wikipedia_ab_all_2017-03"))
.inAdapterView(ViewMatchers.withId(R.id.zimfilelist))
dataInteraction1.atPosition(0).perform(ViewActions.longClick()) // to delete the zim file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.kiwix.kiwixmobile.BaseRobot
import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.download.DownloadTest.Companion.KIWIX_DOWNLOAD_TEST
import org.kiwix.kiwixmobile.testutils.TestUtils
Expand All @@ -58,7 +59,7 @@ class DownloadRobot : BaseRobot() {

fun waitForDataToLoad() {
try {
isVisible(TextId(R.string.your_languages))
isVisible(TextId(string.your_languages))
} catch (e: RuntimeException) {
if (retryCountForDataToLoad > 0) {
retryCountForDataToLoad--
Expand Down Expand Up @@ -155,7 +156,7 @@ class DownloadRobot : BaseRobot() {

private fun assertStopDownloadDialogDisplayed() {
pauseForBetterTestPerformance()
isVisible(TextId(R.string.confirm_stop_download_title))
isVisible(TextId(string.confirm_stop_download_title))
}

private fun clickOnYesButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.Text
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.testutils.TestUtils
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
Expand Down Expand Up @@ -67,7 +68,7 @@ class InitialDownloadRobot : BaseRobot() {

fun waitForDataToLoad(retryCountForDataToLoad: Int = 10) {
try {
isVisible(TextId(R.string.your_languages))
isVisible(TextId(string.your_languages))
} catch (e: RuntimeException) {
if (retryCountForDataToLoad > 0) {
waitForDataToLoad(retryCountForDataToLoad - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.kiwix.kiwixmobile.BaseRobot
import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.main.TopLevelDestinationRobot
import org.kiwix.kiwixmobile.main.topLevel
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
Expand All @@ -37,11 +38,11 @@ class IntroRobot : BaseRobot() {

fun swipeLeft() {
isVisible(ViewId(R.id.get_started))
isVisible(TextId(R.string.welcome_to_the_family))
isVisible(TextId(R.string.humankind_knowledge))
isVisible(TextId(string.welcome_to_the_family))
isVisible(TextId(string.humankind_knowledge))
attempt(10) {
isVisible(TextId(R.string.save_books_offline))
isVisible(TextId(R.string.download_books_message))
isVisible(TextId(string.save_books_offline))
isVisible(TextId(string.download_books_message))
}
}

Expand Down
Loading

0 comments on commit 4a9be43

Please sign in to comment.