Skip to content

Conversation

@csukuangfj
Copy link
Collaborator

@csukuangfj csukuangfj commented Aug 16, 2025

Revert #2488 since it needs to sign the APK.

Fix the following installation error:
59727dbe2bccfdc5db8fb7879b4610d9

Summary by CodeRabbit

  • New Features

    • None
  • Bug Fixes

    • Improved Android APK build reliability by standardizing build outputs.
  • Refactor

    • Removed per-architecture build flags to standardize APK builds.
    • Updated APK locations to match the current Gradle output structure across apps.
  • Behavior Changes

    • Speaker Diarization and Speaker Identification packaging now use debug APK artifacts.
  • Chores

    • Streamlined APK build and packaging scripts for ASR, VAD, KWS, SLID, Audio Tagging, TTS, and related apps.

@coderabbitai
Copy link

coderabbitai bot commented Aug 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Removed per-ABI Gradle flags from many APK build scripts and updated APK artifact paths to Gradle's outputs layout; two speaker-related scripts now run a general build and package debug APKs; TTS script had a minor formatting patch removal.

Changes

Cohort / File(s) Summary
Unified release build updates
scripts/apk/build-apk-asr.sh.in, scripts/apk/build-apk-asr-2pass.sh.in, scripts/apk/build-apk-audio-tagging.sh.in, scripts/apk/build-apk-audio-tagging-wearos.sh.in, scripts/apk/build-apk-kws.sh, scripts/apk/build-apk-slid.sh.in, scripts/apk/build-apk-vad.sh, scripts/apk/build-apk-vad-asr.sh.in, scripts/apk/build-apk-vad-asr-simulate-streaming.sh.in
Removed -Pandroid.injected.build.abi=$arch from Gradle invocations (now ./gradlew assembleRelease); updated APK source path from .../intermediates/.../app-release-unsigned.apk to .../outputs/apk/release/app-release-unsigned.apk; per-arch library copy, naming and cleanup unchanged.
Debug build switch (speaker diarization & identification)
scripts/apk/build-apk-speaker-diarization.sh.in, scripts/apk/build-apk-speaker-identification.sh.in
Replaced ./gradlew assembleRelease -Pandroid.injected.build.abi=$arch with ./gradlew build; changed packaged artifact to .../outputs/apk/debug/app-debug.apk instead of release unsigned APK; per-arch lib handling and cleanup unchanged.
TTS-specific small change
scripts/apk/build-apk-tts.sh.in, scripts/apk/build-apk-tts-engine.sh.in
Minor formatting removal in templated patch; removed per-ABI Gradle flag; updated APK path to .../outputs/apk/release/app-release-unsigned.apk; other packaging steps unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant Script as build script (per-arch loop)
    participant Gradle as ./gradlew
    participant FS as filesystem (APK path)
    Script->>Gradle: ./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
    Gradle-->>FS: produces app-release-unsigned.apk at intermediates/...
    Script->>FS: mv intermediates/.../app-release-unsigned.apk apks/...
    Note over Script,Gradle: OLD (per-ABI build)
Loading
sequenceDiagram
    participant Script as build script (per-arch loop)
    participant Gradle as ./gradlew
    participant FS as filesystem (APK path)
    Script->>Gradle: ./gradlew assembleRelease
    Gradle-->>FS: produces app-release-unsigned.apk at outputs/apk/release/
    Script->>FS: mv outputs/apk/release/app-release-unsigned.apk apks/...
    Note over Script,Gradle: NEW (generic release build)
Loading
sequenceDiagram
    participant Script as speaker build script
    participant Gradle as ./gradlew
    participant FS as filesystem (APK path)
    Script->>Gradle: ./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
    Gradle-->>FS: produces release unsigned APK
    Note over Script,Gradle: OLD
    Script->>Gradle: ./gradlew build
    Gradle-->>FS: produces app-debug.apk at outputs/apk/debug/
    Script->>FS: mv outputs/apk/debug/app-debug.apk apks/...
    Note over Script,Gradle: NEW (build -> debug artifact)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit taps the build machine, light and spry,
I drop the ABI crumbs — they flutter by.
New outputs hum in tidy rows,
Debug or release — wherever it goes.
I hop away with APKs held high. 🐇📦

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 701b8f6 and 19b491c.

📒 Files selected for processing (2)
  • scripts/apk/build-apk-tts-engine.sh.in (1 hunks)
  • scripts/apk/build-apk-tts.sh.in (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/apk/build-apk-tts.sh.in
  • scripts/apk/build-apk-tts-engine.sh.in
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@csukuangfj csukuangfj requested a review from Copilot August 16, 2025 08:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes Android APK build issues by reverting PR #2488 and making necessary adjustments to build scripts. The changes address installation errors caused by signing requirements and standardize the build process across all Android applications.

  • Removes architecture-specific build flags (-Pandroid.injected.build.abi=$arch) from Gradle commands
  • Updates APK file paths from build/intermediates/apk/ to build/outputs/apk/ to match new Gradle output structure
  • Switches Speaker Diarization and Speaker Identification apps to build debug APKs instead of release APKs
  • Removes automatic "kitten" mode assignment in TTS and TTS Engine applications

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/apk/build-apk-vad.sh Removes architecture-specific build flags and updates APK paths for VAD builds
scripts/apk/build-apk-vad-asr.sh.in Updates build command and APK path for VAD+ASR applications
scripts/apk/build-apk-vad-asr-simulate-streaming.sh.in Standardizes build process and removes debug find command for streaming ASR
scripts/apk/build-apk-tts.sh.in Removes kitten mode assignment and updates build process for TTS apps
scripts/apk/build-apk-tts-engine.sh.in Removes kitten mode assignment and updates build process for TTS engine
scripts/apk/build-apk-speaker-identification.sh.in Switches to debug build and updates APK path for speaker identification
scripts/apk/build-apk-speaker-diarization.sh.in Switches to debug build and updates APK path for speaker diarization
scripts/apk/build-apk-slid.sh.in Updates build command and APK path for spoken language identification
scripts/apk/build-apk-kws.sh Standardizes build process for keyword spotting applications
scripts/apk/build-apk-audio-tagging.sh.in Updates build command and APK path for audio tagging
scripts/apk/build-apk-audio-tagging-wearos.sh.in Updates build command and APK path for WearOS audio tagging
scripts/apk/build-apk-asr.sh.in Standardizes build process for ASR applications
scripts/apk/build-apk-asr-2pass.sh.in Updates build command and APK path for 2-pass ASR

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

sed -i.bak s/2048/9012/g ./gradle.properties
git diff ./gradle.properties
./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
./gradlew build
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ./gradlew build instead of ./gradlew assembleRelease is inconsistent with other build scripts and may produce different build outputs. Consider using ./gradlew assembleDebug to be explicit about building debug APKs.

Suggested change
./gradlew build
./gradlew assembleDebug

Copilot uses AI. Check for mistakes.

pushd ./android/SherpaOnnxSpeakerDiarization
./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
./gradlew build
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ./gradlew build instead of ./gradlew assembleRelease is inconsistent with other build scripts and may produce different build outputs. Consider using ./gradlew assembleDebug to be explicit about building debug APKs.

Suggested change
./gradlew build
./gradlew assembleDebug

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (9)
scripts/apk/build-apk-vad-asr-simulate-streaming.sh.in (1)

109-109: Harden APK path resolution for future AGP changes

Instead of hard-coding

mv android/SherpaOnnxSimulateStreamingAsr/app/build/outputs/apk/release/app-release-unsigned.apk … 

discover the unsigned APK at runtime:

# right after: ./gradlew assembleRelease
APK_DIR=android/SherpaOnnxSimulateStreamingAsr/app/build/outputs/apk/release
APK_OUT=$(find "$APK_DIR" -maxdepth 1 -type f -name '*-unsigned.apk' -print -quit)
if [ ! -f "$APK_OUT" ]; then
  echo "Error: no unsigned APK found in $APK_DIR"
  exit 1
fi

mv "$APK_OUT" "./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-simulated_streaming_asr-$lang-$short_name.apk"

• We ran a quick search in android/SherpaOnnxSimulateStreamingAsr/app/build.gradle* and found no splits { abi… } or abiFilters, so there’s only one *-unsigned.apk today.
• If you add ABI splits or filters later, consider failing on >1 match or iterating over all outputs. [optional_refactors_recommended]

scripts/apk/build-apk-asr.sh.in (1)

88-88: Verify APK output naming stability

  • Our quick check did not find any *-unsigned.apk under android/SherpaOnnx/app/build/outputs/apk/release—please confirm that app-release-unsigned.apk is always generated there after assembleRelease.
  • No splits { abi… } or abiFilters settings were detected in the android modules—ensure there are no ABI splits, product flavors, or custom outputFileName rules that could alter the artifact name.

If you expect any variation in the APK filename, consider resolving it dynamically:

- mv android/SherpaOnnx/app/build/outputs/apk/release/app-release-unsigned.apk \
+ APK_OUT=$(ls -1 android/SherpaOnnx/app/build/outputs/apk/release/*-unsigned.apk | head -n 1)
+ if [[ -z "$APK_OUT" || ! -f "$APK_OUT" ]]; then
+   echo "Error: unsigned APK not found"
+   exit 1
+ fi
+ mv "$APK_OUT" \
  ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-asr-$lang-$short_name.apk
scripts/apk/build-apk-asr-2pass.sh.in (1)

110-110: Dynamically resolve unsigned APK output path

To prevent future failures if AGP changes the output layout or introduces build splits, replace the hard-coded APK filename with a runtime lookup.

Affected file:

  • scripts/apk/build-apk-asr-2pass.sh.in (around line 110)

Suggested change:

-  mv android/SherpaOnnx2Pass/app/build/outputs/apk/release/app-release-unsigned.apk \
-     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-asr_2pass-$lang1-${short_name1}_${short_name2}.apk
+  mv "$APK_OUT" \
+     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-asr_2pass-$lang1-${short_name1}_${short_name2}.apk

Add immediately after the Gradle assembleRelease step:

APK_OUT=$(ls -1 android/SherpaOnnx2Pass/app/build/outputs/apk/release/*-unsigned.apk | head -n1)
test -n "$APK_OUT" && test -f "$APK_OUT"

Please build the release variant locally and verify that the glob (*-unsigned.apk) matches the actual output file before committing.

scripts/apk/build-apk-audio-tagging-wearos.sh.in (1)

81-81: Prefer dynamic APK discovery (including architecture) before mv to handle AGP filename changes

The hard-coded path may break if AGP tweaks the output name. Since there are no ABI splits configured, we can glob on *-${arch}-unsigned.apk and fall back if nothing matches. Please verify this on your CI environment.

• File: scripts/apk/build-apk-audio-tagging-wearos.sh.in
• Line: 81

-  mv android/SherpaOnnxAudioTaggingWearOs/app/build/outputs/apk/release/app-release-unsigned.apk \
-     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-audio-tagging-$short_name-wearos.apk
+  APK_OUT=$(ls -1 \
+    android/SherpaOnnxAudioTaggingWearOs/app/build/outputs/apk/release/*-${arch}-unsigned.apk \
+    | head -n1)
+  if [ -z "$APK_OUT" ] || [ ! -f "$APK_OUT" ]; then
+    echo "ERROR: unsigned APK not found (searched for *-${arch}-unsigned.apk)" >&2
+    exit 1
+  fi
+  mv "$APK_OUT" \
+     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-audio-tagging-$short_name-wearos.apk

• Quick scan showed no abiFilters or splits { abi … } in the Android module, so this glob will match the single unsigned APK.
Action: Please confirm that this pattern reliably locates the unsigned APK in your build pipeline.

scripts/apk/build-apk-slid.sh.in (1)

84-84: Guard APK output path dynamically

Minor robustness improvement: derive the unsigned APK file name instead of hardcoding it.

Files to update:

  • scripts/apk/build-apk-slid.sh.in

Changes needed:

  • After the assembleRelease invocation, insert:

    APK_OUT=$(ls -1 android/SherpaOnnxSpokenLanguageIdentification/app/build/outputs/apk/release/*-unsigned.apk)
    if [ -z "$APK_OUT" ]; then
      echo "Error: unsigned APK not found" >&2
      exit 1
    fi
  • On line 84 (the mv command), replace the hardcoded path:

    -  mv android/SherpaOnnxSpokenLanguageIdentification/app/build/outputs/apk/release/app-release-unsigned.apk \
    -     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-slid-$short_name.apk
    +  mv "$APK_OUT" \
    +     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-slid-$short_name.apk

Note: Searching under android/ for abiFilters or splits { abi returned no results, so currently only one *-unsigned.apk is produced. If ABI splits are ever added, you’ll need to refine the glob or selection logic to handle multiple outputs.

Please verify after a release build that APK_OUT correctly matches the actual artifact name.

scripts/apk/build-apk-speaker-identification.sh.in (2)

72-72: Prefer assembleDebug over build for precision and speed

./gradlew build runs more tasks than needed (incl. tests), and may assemble other variants. assembleDebug is faster and aligns with the debug APK you package below.

Apply this diff:

-  ./gradlew build
+  ./gradlew assembleDebug

75-75: Confirm intent to ship a debug-signed APK

You’re packaging app-debug.apk, which is debug-signed and installable (good for fixing install errors). Just confirm this variant choice is intentional for speaker identification while other scripts use release-unsigned.

scripts/apk/build-apk-vad.sh (1)

61-64: LGTM: Release build and new outputs path

Using assembleRelease and moving from intermediates to outputs aligns with modern AGP behavior.

As a minor optimization, consider excluding non-essential tasks to speed packaging (example: ./gradlew assembleRelease -x lint -x test) if CI time is a concern.

scripts/apk/build-apk-kws.sh (1)

80-84: Optional: guard the artifact move to improve robustness across AGP versions

In case AGP/Gradle alters output locations, consider globbing or finding the latest debug APK to avoid brittle paths.

Example:

apk_path=$(ls -1 android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk 2>/dev/null || true)
test -f "$apk_path" || { echo "APK not found"; exit 1; }
mv "$apk_path" "./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-<desc>.apk"

Replace as appropriate for each loop.

Also applies to: 141-145

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4dfb39c and 701b8f6.

📒 Files selected for processing (13)
  • scripts/apk/build-apk-asr-2pass.sh.in (1 hunks)
  • scripts/apk/build-apk-asr.sh.in (1 hunks)
  • scripts/apk/build-apk-audio-tagging-wearos.sh.in (1 hunks)
  • scripts/apk/build-apk-audio-tagging.sh.in (1 hunks)
  • scripts/apk/build-apk-kws.sh (2 hunks)
  • scripts/apk/build-apk-slid.sh.in (1 hunks)
  • scripts/apk/build-apk-speaker-diarization.sh.in (1 hunks)
  • scripts/apk/build-apk-speaker-identification.sh.in (1 hunks)
  • scripts/apk/build-apk-tts-engine.sh.in (1 hunks)
  • scripts/apk/build-apk-tts.sh.in (1 hunks)
  • scripts/apk/build-apk-vad-asr-simulate-streaming.sh.in (1 hunks)
  • scripts/apk/build-apk-vad-asr.sh.in (1 hunks)
  • scripts/apk/build-apk-vad.sh (2 hunks)
🔇 Additional comments (11)
scripts/apk/build-apk-vad-asr-simulate-streaming.sh.in (1)

106-106: Dropping per-ABI Gradle flag looks fine

Using assembleRelease without -Pandroid.injected.build.abi relies on per-arch jniLibs population (as you already do). That should still yield single-ABI APKs per loop iteration. No objections here.

scripts/apk/build-apk-asr.sh.in (1)

85-85: assembleRelease without ABI injection is reasonable

Given you copy only one ABI’s .so files per iteration, dropping -Pandroid.injected.build.abi should still produce per-ABI APKs. This aligns with the revert goal and removes the signing dependency.

scripts/apk/build-apk-asr-2pass.sh.in (1)

107-107: LGTM on reverting ABI injection

assembleRelease without per-ABI override should still yield per-ABI APKs per loop, given the jniLibs staging you already do. This supports the revert intent cleanly.

scripts/apk/build-apk-audio-tagging-wearos.sh.in (1)

78-78: assembleRelease change aligns with the revert and is fine

Removing ABI injection here is consistent with the other scripts and with per-arch jniLibs handling. No issues spotted.

scripts/apk/build-apk-slid.sh.in (1)

81-81: assembleRelease without ABI param: OK

Given the per-arch library copy pattern, this should still result in per-ABI APKs and removes the need for ABI injection. Looks good.

scripts/apk/build-apk-audio-tagging.sh.in (2)

77-77: LGTM: Dropped per-ABI Gradle param

Using plain ./gradlew assembleRelease is fine given you inject per-arch libs under jniLibs/$arch before building.


80-80: Verified AGP output layout — no legacy references remain

No occurrences of android.injected.build.abi or intermediates/apk/release were found, and all APK move commands now consistently use build/outputs/apk/.... LGTM.

scripts/apk/build-apk-vad.sh (1)

104-107: LGTM: Consistent update for ten-vad variant

Same rationale as above — looks correct and consistent for the second variant.

scripts/apk/build-apk-vad-asr.sh.in (1)

86-89: LGTM: Assemble release + outputs path

The switch to assembleRelease and the updated APK path to outputs/apk/release are correct.

scripts/apk/build-apk-tts-engine.sh.in (1)

139-142: LGTM: Assemble release and updated APK output path

This aligns with the revert and matches AGP’s outputs/apk/release structure.

scripts/apk/build-apk-speaker-diarization.sh.in (1)

79-79: LGTM on switching to a debug artifact path

This aligns with generating an installable APK without manual signing. Once assembleDebug is used (above), this path is correct.

sed -i.bak s/2048/9012/g ./gradle.properties
git diff ./gradle.properties
./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
./gradlew assembleRelease
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Release build will yield an unsigned APK; prefer debug to fulfill the “no signing needed” objective

To avoid installation failures and keep behavior consistent with the diarization script, assemble the debug variant.

Apply:

-  ./gradlew assembleRelease
+  ./gradlew assembleDebug
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
./gradlew assembleRelease
./gradlew assembleDebug
🤖 Prompt for AI Agents
In scripts/apk/build-apk-kws.sh around line 80, the script calls ./gradlew
assembleRelease which produces an unsigned release APK and can cause install
failures; change this to assemble the debug variant by replacing that call with
./gradlew assembleDebug so the produced APK is signed with the debug key and
requires no manual signing, matching the diarization script behavior.

popd

mv android/SherpaOnnxKws/app/build/intermediates/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk
mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update APK path to the debug artifact if switching to assembleDebug

Match the path to the debug build output.

Apply:

-  mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk
+  mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk
🤖 Prompt for AI Agents
In scripts/apk/build-apk-kws.sh around line 83, the script moves the release
unsigned APK but the build was switched to assembleDebug; update the destination
path to point to the debug artifact under build/outputs/apk/debug (replace
android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk
with android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk) and keep
the same target filename pattern
(./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk).

sed -i.bak s/2048/9012/g ./gradle.properties
git diff ./gradle.properties
./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
./gradlew assembleRelease
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Same here: assembleDebug to avoid signing-related failures

Mirror the change for the English model loop.

Apply:

-  ./gradlew assembleRelease
+  ./gradlew assembleDebug
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
./gradlew assembleRelease
./gradlew assembleDebug
🤖 Prompt for AI Agents
In scripts/apk/build-apk-kws.sh around line 141, change the Gradle task from
assembleRelease to assembleDebug to avoid signing-related failures; replace the
./gradlew assembleRelease call with ./gradlew assembleDebug at this location and
mirror the same replacement in the English model loop elsewhere in the script so
both loops build debug APKs instead of release ones.

popd

mv android/SherpaOnnxKws/app/build/intermediates/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Match the debug APK path in the second loop

Use the debug artifact path for consistency and installability.

Apply:

-  mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
+  mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
🤖 Prompt for AI Agents
In scripts/apk/build-apk-kws.sh around line 144, the mv command moves the
release unsigned APK but the second loop should use the debug artifact path for
consistency and installability; change the source path from
android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk to
the debug artifact path
android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk (keep the
destination filename pattern the same).


pushd ./android/SherpaOnnxSpeakerDiarization
./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
./gradlew build
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Using “gradlew build” may still trigger release tasks (and signing); use assembleDebug

gradlew build typically depends on assemble for all build types, which can invoke assembleRelease and reintroduce signing requirements. Use assembleDebug to ensure only a debug-signed, installable APK is produced.

Apply:

-  ./gradlew build
+  ./gradlew assembleDebug
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
./gradlew build
./gradlew assembleDebug
🤖 Prompt for AI Agents
In scripts/apk/build-apk-speaker-diarization.sh.in around line 76, the script
runs "./gradlew build" which can trigger release tasks and signing; replace that
invocation with "./gradlew assembleDebug" so only a debug-signed installable APK
is produced. Update the line to call assembleDebug and ensure any downstream
steps that expect the APK path point to the debug APK output directory.

sed -i.bak s/2048/9012/g ./gradle.properties
git diff ./gradle.properties
./gradlew assembleRelease -Pandroid.injected.build.abi=$arch
./gradlew assembleRelease
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Release build here still requires manual signing; prefer debug to meet the “install without signing” goal

assembleRelease produces an unsigned APK. To actually fix the installation error without introducing signing requirements, switch to assembleDebug (consistent with the diarization script’s direction).

Apply:

-  ./gradlew assembleRelease
+  ./gradlew assembleDebug

If you intentionally want release unsigned artifacts, please confirm and we can instead add an apksigner step using the debug keystore.


🏁 Script executed:

#!/bin/bash
# Display lines around 133 in the TTS build script
sed -n '120,150p' scripts/apk/build-apk-tts.sh.in

# Check for any existing use of assembleDebug in APK scripts
rg -n 'assembleDebug' -g 'scripts/apk/*'

Length of output: 919


Use a debug build to auto-sign the APK for immediate installation

The current assembleRelease step produces an unsigned APK (app-release-unsigned.apk), which won’t install without manual signing. Switching to assembleDebug yields a debug‐signed APK that can be installed out-of-the-box.

Please update scripts/apk/build-apk-tts.sh.in as follows:

  • Replace the release assemble step
  • Update the APK path in the mv command
-  ./gradlew assembleRelease
+  ./gradlew assembleDebug

-  mv android/SherpaOnnxTts/app/build/outputs/apk/release/app-release-unsigned.apk \
-     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk
+  mv android/SherpaOnnxTts/app/build/outputs/apk/debug/app-debug.apk \
+     ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk

If you instead need an unsigned release artifact, let me know and we can add an apksigner step using the debug keystore.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
./gradlew assembleRelease
./gradlew assembleDebug
mv android/SherpaOnnxTts/app/build/outputs/apk/debug/app-debug.apk \
./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk
🤖 Prompt for AI Agents
In scripts/apk/build-apk-tts.sh.in at line 133, replace the release assemble
step and move target so the script builds and uses the debug-signed APK; change
the gradle task from ./gradlew assembleRelease to ./gradlew assembleDebug and
update the subsequent mv command to reference the debug APK path (e.g.
app/build/outputs/apk/debug/app-debug.apk) instead of the release-unsigned APK
so the produced APK is debug-signed and installable immediately.

popd

mv android/SherpaOnnxTts/app/build/intermediates/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk
mv android/SherpaOnnxTts/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

APK path should match the selected build type

If switching to assembleDebug per the previous comment, this path must point to the debug artifact.

Apply:

-  mv android/SherpaOnnxTts/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk
+  mv android/SherpaOnnxTts/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk

Optionally make this more robust across AGP versions by searching for the artifact:

apk_path=$(ls -1 android/SherpaOnnxTts/app/build/outputs/apk/debug/app-debug.apk 2>/dev/null || true)
test -f "$apk_path" || { echo "APK not found"; exit 1; }
mv "$apk_path" "./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk"
🤖 Prompt for AI Agents
In scripts/apk/build-apk-tts.sh.in around line 136, the mv command references
the release APK while the build now uses the debug variant; update the path to
point to the debug artifact
(android/SherpaOnnxTts/app/build/outputs/apk/debug/app-debug.apk) or,
preferably, implement a robust lookup that finds the debug APK (e.g., assign
apk_path by checking the expected debug location(s), verify the file exists, and
then mv that resolved path to
./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-$lang-tts-$model_dir.apk),
exiting with an error if no APK is found.

@csukuangfj csukuangfj merged commit beb700a into k2-fsa:master Aug 16, 2025
1 check passed
@csukuangfj csukuangfj deleted the fix-building-apk branch August 16, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant