From 9a7ce1a8fd46673e91141632397106f66911d871 Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:09:56 +0100 Subject: [PATCH 1/4] build: add `:rsdroid-android` Create `:rsdroid-android `with an API dependency on `:rsdroid`. Assisted-by: GPT-6.1-Sol xhigh Assisted-by: GPT-6-Astra xhigh --- .github/workflows/build-quick.yml | 2 +- check-droid.bat | 2 +- check-droid.sh | 2 +- rsdroid-android/README.md | 14 +++++++++ rsdroid-android/build.gradle | 48 ++++++++++++++++++++++++++++++ rsdroid-android/consumer-rules.pro | 0 rsdroid-android/proguard-rules.pro | 21 +++++++++++++ settings.gradle.kts | 2 +- 8 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 rsdroid-android/README.md create mode 100644 rsdroid-android/build.gradle create mode 100644 rsdroid-android/consumer-rules.pro create mode 100644 rsdroid-android/proguard-rules.pro diff --git a/.github/workflows/build-quick.yml b/.github/workflows/build-quick.yml index 83a8560d0..b0db22732 100644 --- a/.github/workflows/build-quick.yml +++ b/.github/workflows/build-quick.yml @@ -261,7 +261,7 @@ jobs: run: ./check-rust.bat - name: Run tests (Unit) - run: ./gradlew test rsdroid:lint ktlintCheck --daemon + run: ./gradlew test rsdroid:lint rsdroid-android:lint ktlintCheck --daemon - name: Run tests (Emulator) uses: reactivecircus/android-emulator-runner@v2 diff --git a/check-droid.bat b/check-droid.bat index 061832cc8..b49f9db41 100755 --- a/check-droid.bat +++ b/check-droid.bat @@ -3,4 +3,4 @@ if not exist rsdroid\build\outputs\aar\rsdroid-release.aar ( exit 1 ) -./gradlew rsdroid:lint rsdroid-instrumented:connectedCheck +./gradlew rsdroid:lint rsdroid-android:lint rsdroid-instrumented:connectedCheck diff --git a/check-droid.sh b/check-droid.sh index 2101d8c0b..8a5431096 100755 --- a/check-droid.sh +++ b/check-droid.sh @@ -9,4 +9,4 @@ test -f rsdroid/build/outputs/aar/rsdroid-release.aar || ( . ./set-android-ndk-home.sh -./gradlew rsdroid:lint rsdroid-instrumented:connectedCheck +./gradlew rsdroid:lint rsdroid-android:lint rsdroid-instrumented:connectedCheck diff --git a/rsdroid-android/README.md b/rsdroid-android/README.md new file mode 100644 index 000000000..e5401aa24 --- /dev/null +++ b/rsdroid-android/README.md @@ -0,0 +1,14 @@ +# rsdroid-android + +Android entry point for the Anki backend. This Android library exposes +[`:rsdroid`](../rsdroid) through an `api` dependency, so consumers can use the +backend API through this module. + +## Planned contents + +After the split, `anki-backend-android` will contain: + +- Android native libraries (`librsdroid.so` for each supported architecture). +- Web assets packaged as Android assets. +- Android SQLite adapters. + - Planned to be extracted later. \ No newline at end of file diff --git a/rsdroid-android/build.gradle b/rsdroid-android/build.gradle new file mode 100644 index 000000000..c13200997 --- /dev/null +++ b/rsdroid-android/build.gradle @@ -0,0 +1,48 @@ +plugins { + alias(libs.plugins.android.library) +} + +android { + namespace = 'net.ankiweb.rsdroid.android' + compileSdk = libs.versions.compileSdk.get().toInteger() + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInteger() + + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled = false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + testOptions { + targetSdk = libs.versions.targetSdk.get().toInteger() + } + + lint { + targetSdk = libs.versions.targetSdk.get().toInteger() + } +} + +dependencies { + api project(path: ':rsdroid') + + implementation libs.androidx.annotation + implementation libs.androidx.sqlite.ktx + implementation libs.androidx.sqlite.framework + implementation libs.slf4j.api + + testImplementation libs.robolectric + testImplementation libs.androidx.core + testImplementation libs.androidx.test.junit + testImplementation project(path: ':rsdroid-testing') +} diff --git a/rsdroid-android/consumer-rules.pro b/rsdroid-android/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/rsdroid-android/proguard-rules.pro b/rsdroid-android/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/rsdroid-android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 38e95587c..7076d7dc9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,4 +8,4 @@ pluginManagement { rootProject.name = "Anki-Android-Backend" -include(":rsdroid-testing", ":rsdroid-instrumented", ":rsdroid") \ No newline at end of file +include(":rsdroid-testing", ":rsdroid-instrumented", ":rsdroid", ":rsdroid-android") From 56f6608993f9e1a4fde3ab9d01c9a05725f3be26 Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:35:03 +0000 Subject: [PATCH 2/4] build: publish a backend Android wrapper as `anki-backend-android` The intention is for this to be alongside a JVM `anki-android-core` artifact. For now, this sets up the Android artifact and publishing to ensure that the pipeline & dependencies resolve successfully. Assisted-by: GPT-6-Astra xhigh --- README.md | 4 +++- rsdroid-android/build.gradle | 15 ++++++--------- rsdroid-android/gradle.properties | 5 +++++ 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 rsdroid-android/gradle.properties diff --git a/README.md b/README.md index fc880044b..388be0930 100644 --- a/README.md +++ b/README.md @@ -90,10 +90,12 @@ set PATH=%PATH%;c:\msys64\usr\bin ## Building -Two main files need to be built: +The build produces three artifacts: - The main .aar file, which contains the backend Kotlin code, web assets, and Anki backend code compiled for Android. +- An Android wrapper .aar in `rsdroid-android/build/outputs/aar`. Its published +Maven metadata declares an API dependency on the main backend artifact. - A .jar that contains the backend code compiled for the host platform, for use with Robolectric unit tests. diff --git a/rsdroid-android/build.gradle b/rsdroid-android/build.gradle index c13200997..1a04c2e99 100644 --- a/rsdroid-android/build.gradle +++ b/rsdroid-android/build.gradle @@ -1,5 +1,7 @@ plugins { alias(libs.plugins.android.library) + id 'signing' + alias(libs.plugins.gradle.maven.publish.plugin) } android { @@ -35,14 +37,9 @@ android { dependencies { api project(path: ':rsdroid') +} - implementation libs.androidx.annotation - implementation libs.androidx.sqlite.ktx - implementation libs.androidx.sqlite.framework - implementation libs.slf4j.api - - testImplementation libs.robolectric - testImplementation libs.androidx.core - testImplementation libs.androidx.test.junit - testImplementation project(path: ':rsdroid-testing') +mavenPublishing { + publishToMavenCentral(true) + signAllPublications() } diff --git a/rsdroid-android/gradle.properties b/rsdroid-android/gradle.properties new file mode 100644 index 000000000..82bbe496d --- /dev/null +++ b/rsdroid-android/gradle.properties @@ -0,0 +1,5 @@ +POM_ARTIFACT_ID=anki-backend-android +POM_PACKAGING=aar + +POM_NAME=Anki Backend (Android) +POM_DESCRIPTION=Android entry point for the Anki backend From 38c62cf3a379557b7dff50ce83cb4b4553210625 Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:35:16 +0000 Subject: [PATCH 3/4] build(ci): publish `anki-backend-android` Assisted-by: GPT-6-Astra xhigh --- .github/workflows/build-quick.yml | 8 ++++++++ .github/workflows/build-release.yml | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-quick.yml b/.github/workflows/build-quick.yml index b0db22732..9846a93ee 100644 --- a/.github/workflows/build-quick.yml +++ b/.github/workflows/build-quick.yml @@ -287,6 +287,14 @@ jobs: if-no-files-found: error path: rsdroid/build/outputs/aar + - name: Upload Android wrapper AAR as artifact + uses: actions/upload-artifact@v6 + if: '!cancelled()' + with: + name: rsdroid-android-aar-${{ matrix.os }} + if-no-files-found: error + path: rsdroid-android/build/outputs/aar + - name: Upload rsdroid-robo JAR as artifact uses: actions/upload-artifact@v6 if: '!cancelled()' diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 4bbeaba85..a794e8f42 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -175,6 +175,13 @@ jobs: if-no-files-found: error path: rsdroid/build/outputs/aar + - name: Upload Android wrapper AAR as artifact + uses: actions/upload-artifact@v6 + with: + name: rsdroid-android-aar + if-no-files-found: error + path: rsdroid-android/build/outputs/aar + - name: Upload rsdroid-robo JAR as artifact uses: actions/upload-artifact@v6 with: @@ -184,7 +191,7 @@ jobs: # following steps only run on workflow dispatch - - name: Publish AAR to Maven + - name: Publish backend and Android wrapper AARs to Maven if: "${{ github.event.inputs.mavenPublish != '' && github.event_name == 'workflow_dispatch'}}" env: ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }} @@ -192,7 +199,7 @@ jobs: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} run: | - ./gradlew rsdroid:publishAllPublicationsToMavenCentral -DtestBuildType=release -Dorg.gradle.daemon=false -Dorg.gradle.console=plain + ./gradlew rsdroid:publishAllPublicationsToMavenCentral rsdroid-android:publishAllPublicationsToMavenCentral -DtestBuildType=release -Dorg.gradle.daemon=false -Dorg.gradle.console=plain - name: Publish JAR to Maven if: "${{ github.event.inputs.mavenPublish != '' && github.event_name == 'workflow_dispatch'}}" From f77ad6d10d932e851dfe5ee8f90495564561455f Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Sun, 25 Oct 2026 17:10:30 +0000 Subject: [PATCH 4/4] build: bump version to 0.1.73-anki26.09.3 The first release to include `anki-backend-android`: * `anki-android-backend` will later be converted to a `java-library` and renamed to `anki-backend-core`. This is the Android dependency which will contain the `.so` files and Android assets required for the backend to function as an AAR. This will depend on, and bring in `anki-backend-core` Assisted-by: GPT-6-Astra xhigh --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c6c74ac44..44d487f5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ android.useAndroidX=true android.enableJetifier=false GROUP=io.github.david-allison -VERSION_NAME=0.1.72-anki26.09.3 +VERSION_NAME=0.1.73-anki26.09.3 POM_INCEPTION_YEAR=2020