From Newsgroup: comp.mobile.android
Tutorial:
Build your first Android APK on Windows from Github WhisperIME src code
This is a first-pass, written ad hoc... as the work was being done.
It's my first "build" of a professional APK so work with me together.
a. Compiling (Java/Kotlin) files into .class bytecode
b. Dexing those .class files into Dalvik Executable files for ART
c. Resource packaging of XML layouts & images to generate R.java files
d. Linking & packaging all the above & more into an APK Android package
e. Signing with a debug key for testing purposes
f. Installing/deploying the APK to the device & launch for testing
Here's a "packaged tutorial" which incorporates "strategic decisions". Therefore, default filespecs & variables can differ than those I chose.
1. Download (but do not RUN!) the latest Android Studio for Windows
Save to C:\software\editor\android\studio\.
"Android Studio Narwhal Feature Drop|2025.1.2 Patch 1"
<
https://developer.android.com/studio/install>
<
https://developer.android.com/studio>
<
https://developer.android.com/studio/releases/>
<Save to C:\software\editor\android\studio\.>
Name: android-studio-2025.1.2.12-windows.exe
Size: 1494432920 bytes (1425 MiB)
SHA256: B62977A08079D438F5FFECC8B61C0C00D8E90AF556A523794C51E17AD3E12A36
2. One by one we're replacing Google packages on unrooted Android where
Qihe kindly suggested the Github WhisperIME tool which replaces the
native Google voice search & speech-to-text package.
So download (but do not unzip!) the latest WhisperIME source code.
<
https://github.com/woheller69/whisperIMEplus>
<
https://github.com/woheller69/whisperIME/releases>
<
https://github.com/woheller69/whisperIME/archive/refs/tags/V3.4.zip>
Save to C:\software\editor\android\project\whisperime\.
Name: whisperIME-3.4.zip
Size: 1087646 bytes (1062 KiB)
SHA256: 5341E96EEBF5176BD7A58CDBB1E3408098DFA9A0888C2F7E7F0E6F73E2293D8B
3. Download the Java which Android Studio & WhisperIME are expecting.
<
https://learn.microsoft.com/en-us/java/openjdk/download>
<
https://aka.ms/download-jdk/microsoft-jdk-21.0.8-windows-x64.zip>
Save to C:\software\editor\android\java\.
4. Unzip and move the contents of that unzipped folder (i.e., the dir
containing bin\java.exe) directly into C:\app\editor\android\java
Name: microsoft-jdk-21.0.8-windows-x64.zip
Size: 200855809 bytes (191 MiB)
SHA256: 6ECFA864B95A45CDE05D92351EDF06D33B778669499B485BB8414145704FAE0A
Verify with: C:\app\editor\android\java\bin\java.exe -version
Which reported, for me just now:
openjdk version "21.0.8" 2025-07-15 LTS
OpenJDK Runtime Environment Microsoft-11933218 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Microsoft-11933218 (build 21.0.8+9-LTS, mixed mode, sharing)
5. Install Android Studio by running the downloaded installer executable.
android-studio-2025.1.2.12-windows.exe
Do not let the installer start up the Android Studio application!
Do not let it install emulators (due to inherent Windows complexities).
Tell it to install Android Studio to C:\software\editor\android\studio
If it wants to install an SDK, use C:\app\editor\android\sdk
Cancel/close Android Studio when the Setup Wizard offers to start it!
6. We will maintain each GitHub repo in its own project subfolder.
To that end, unzip & move the contents of the WhisperIME zip file to
C:\app\editor\android\project\whisperime
7. Determine/set/check/update the necessary variables with this script.
It does not use any absurd Microsoft/Google garbage-bin directories!
runstudio.cmd (appended at the end of this tutorial)
Rest assured Android Studio is a complex assemblage of Google stuff.
The FIRST time you run it, you will have a while to wait for stuff.
The first time you run this, Android Studio may ask you to
"Trust and Open Project 'whisperime'?
[_]Trust all projects in 'project' folder
[x]Add IDE and 'whisperime' folders to the Microsoft Defender exclusions list?
[Trust Project][Preview in Safe Mode][Don't Open]
Click the [Trust Project] button (if you trust the project).
You may also get the message (due to poor WhisperIME packagin) of...
Sync Android SDKs
The SDK path '\home\wolfgang\Android\Sdk' does not belong to a directory.
Android Studio will use this Android SDK instead:
C:\app\editor\android\sdk'
and will modify the project's local properties file.
[OK] <== just press the button as it will fix it
And you need to accept a UAC prompt for Android Studio's elevator.
Do you want to allow this app to make changes to this device?
Part of elevator/launcher UAC IntelliJ kit.
Verified publisher Google LLC. File origin:
C:\app\editor\android\studio\bin\elevator.exe (lots more)...
You may see a warning due to how we set the JAVA variables...
The use of Java options environment variables detected.
Such variables override IDE configuration files (.vmoptions)
and may cause performance and stability issues.
Please consider deleting these variables:
JAVA_TOOL_OPTIONS [Don't show again]
I have a slow machine so mine also gives the classic warning...
Gradle project sync in progress...
Sync is taking a significant amount of time to download dependencies.
Open Sync tool window for details.
BUILD SUCCESSFUL in 9m 51s
Then you may get the suggestions... (which I ignored)
Project update is recommended
Android Gradle plugin version 8.2.2 has an upgrade available
Start the AGP...
[Start AGP Upgrade Assistant]
Kotlin version 2.1.10 is available.
8. Once Android Studio has done the first-time-run housekeeping,
From the top bar, choose "Build" & then "Assemble Project".
It will take a while & you may get sloppy-code warnings of
":app:compileDebugKotlin Parameter view is never used".
The important thing is no red ERROR lines.
When this build finishes, you'll be able to pick up the APK
from app/build/outputs/apk/debug and try it on your device.
Eventually you'll get a message similar to mine of
"Gradle build finished in 4m 2s 997ms"
You should end up with two files in the whisperime folder:
C:\app\editor\android\project\whisperime\
app\build\outputs\apk\debug\app-debug.apk
app\build\outputs\apk\debug\output-metadata.json
9. Assuming your phone is set up for adb installations and
assuming your phone is connected via USB to Windows,
you may need to click an "Allow" button on your phone.
C:\> adb install -r "C:\app\editor\android\project\whisperime\app\build\outputs\apk\debug\app-debug.apk"
Performing Streamed Install
Success
10. On Android, search for the purple "Whisper" mic icon.
At this point, the app does whatever it's designed to do.
Click the button asking "Download Model" to download the
huge Speech-to-text model files from Hugging Face's hub.
<
https://huggingface.co/openai/whisper-large-v3>
When it's done downloading the 435MB STT model file,
press the Whisper "Start" button & accept permissions
"Allow Whisper to record audio? While using the app."
"Allow Whisper to send you notifications? Allow."
This should add "Whisper Voice Input" to your keyboards.
=====================================================================
runstudio.cmd 20250822 rev 1.4 - Launch Android Studio w/ checks =====================================================================
@echo off
REM runstudio.cmd 20250822 rev 1.0
REM Purpose: Launch Android Studio with WhisperIME project
REM Archives stay in C:\software, live project in:
REM C:\app\editor\android\project\whisperime
setlocal
REM === Whisper IME Project Path ===
set "WHISPERIME_HOME=C:\app\editor\android\project\whisperime"
if not exist "%WHISPERIME_HOME%" (
echo [ERROR] Project folder not found:
echo %WHISPERIME_HOME%
echo Unzip WhisperIME source from
echo C:\software\editor\android\project\whisperime
goto :EOF
)
REM === Android SDK and Tools ===
set "ANDROID_SDK_ROOT=C:\app\editor\android\sdk"
set "ANDROID_HOME=%ANDROID_SDK_ROOT%"
set "ANDROID_SDK_HOME=C:\app\editor\android\dot_android"
REM === Java ===
set "JAVA_HOME=C:\app\editor\android\java"
set "JAVA_TOOL_OPTIONS=-Duser.home=C:\app\editor\android\java_home"
REM === Temporary PATH for this run ===
set "PATH=%ANDROID_SDK_ROOT%\platform-tools;%JAVA_HOME%\bin;%PATH%"
REM === Check Java existence and version banner ===
if not exist "%JAVA_HOME%\bin\java.exe" (
echo [ERROR] JDK 21 not found at %JAVA_HOME%
echo Please install/unzip Microsoft JDK 21 into this path from:
echo C:\software\editor\android\java\microsoft-jdk-21.0.8...
goto :EOF
) else (
for /f "tokens=*" %%v in ('"%JAVA_HOME%\bin\java.exe" -version 2^>^&1') do (
if not defined _java_ver set "_java_ver=%%v"
)
echo [INFO] Java found: %_java_ver%
)
REM === Check Android SDK platform-tools (adb.exe) ===
if not exist "%ANDROID_SDK_ROOT%\platform-tools\adb.exe" (
echo [ERROR] Android SDK platform-tools not found at %ANDROID_SDK_ROOT%
echo Please install/unzip SDK from C:\software into this working path.
goto :EOF
)
REM === Check for Android Studio executable ===
if not exist "C:\app\editor\android\studio\bin\studio64.exe" (
echo [ERROR] Android Studio not found in:
echo C:\app\editor\android\studio
echo Install/unzip Studio from:
echo C:\software\editor\android\studio\android-studio-2025...
goto :EOF
)
REM === Launch Studio with project loaded ===
echo.
echo Launching Android Studio with WhisperIME project...
start "" "C:\app\editor\android\studio\bin\studio64.exe" "%WHISPERIME_HOME%"
endlocal
BONUS material! Once Android Studio has done the initial setup...
a. Downloading and syncing billions of Gradle dependencies
b. Setting up the local environment (Java, Android SDK, build tools)
c. Generating any first-time caches or configuration files
You could close Android Studio entirely and still build from the
command line using the buildwhisperime.cmd included below.
@echo off
REM buildwhisperime.cmd 20250822 rev 1.0
REM Purpose: Build or open WhisperIME project in a clean, controlled env
REM Archives remain in C:\software, unzipped project in:
REM C:\app\editor\android\project\whisperime
setlocal
REM === Ensure working project folder exists ===
if not exist "C:\app\editor\android\project\whisperime" (
echo [ERROR] Project folder not found:
echo C:\app\editor\android\project\whisperime
echo Unzip WhisperIME source from C:\software\editor\android\project\whisperime into this folder first.
goto :EOF
)
REM === Android SDK and Tools ===
set "ANDROID_SDK_ROOT=C:\app\editor\android\sdk"
set "ANDROID_HOME=%ANDROID_SDK_ROOT%"
set "ANDROID_SDK_HOME=C:\app\editor\android\dot_android"
REM === Gradle ===
set "GRADLE_USER_HOME=C:\app\editor\android\gradle"
REM === Java ===
set "JAVA_HOME=C:\app\editor\android\java"
set "JAVA_TOOL_OPTIONS=-Duser.home=C:\app\editor\android\java_home"
REM === Kotlin ===
set "KOTLIN_HOME=C:\app\editor\android\kotlin"
REM === Whisper IME ===
set "WHISPERIME_HOME=C:\app\editor\android\project\whisperime"
REM === Temporary PATH injection for this session only ===
set "PATH=%ANDROID_SDK_ROOT%\platform-tools;%JAVA_HOME%\bin;%PATH%"
REM === Existence checks for critical tools ===
if not exist "%JAVA_HOME%\bin\java.exe" (
echo [ERROR] JDK 21 not found at %JAVA_HOME%
echo Please install/unzip Microsoft JDK 21 into this path from:
echo C:\software\editor\android\java\microsoft-jdk-21.0.8-windows-x64.zip
goto :EOF
) else (
for /f "tokens=*" %%v in ('"%JAVA_HOME%\bin\java.exe" -version 2^>^&1') do (
if not defined _java_ver set "_java_ver=%%v"
)
echo [INFO] Java found: %_java_ver%
)
if not exist "%ANDROID_SDK_ROOT%\platform-tools\adb.exe" (
echo [ERROR] Android SDK platform-tools not found at %ANDROID_SDK_ROOT%
echo Please install/unzip SDK from C:\software into this working path.
goto :EOF
)
REM === Choose action: BUILD or OPEN in Studio ===
echo.
echo ============================================================
echo WhisperIME Build/Run Environment
echo rev 1.2 (archives in C:\software, active work in C:\app)
echo ============================================================
echo 1 - Build APK via Gradle (no Studio)
echo 2 - Open in Android Studio
echo ============================================================
set /p choice="Select option [1/2]: "
if "%choice%"=="1" (
echo.
echo Building WhisperIME APK...
pushd "%WHISPERIME_HOME%"
if exist gradlew (
call gradlew assembleDebug
) else (
echo [ERROR] gradlew script not found in project root.
)
popd
goto :EOF
)
if "%choice%"=="2" (
if not exist "C:\app\editor\android\studio\bin\studio64.exe" (
echo [ERROR] Android Studio not found in C:\app\editor\android\studio
goto :EOF
)
echo.
echo Launching Android Studio with WhisperIME project loaded...
start "" "C:\app\editor\android\studio\bin\studio64.exe" "%WHISPERIME_HOME%"
goto :EOF
)
echo [ERROR] Invalid selection. Please run again and choose 1 or 2.
endlocal
In summary, my first APK build was successful, so this "should" work
for you too, but it is a very complex process to do the first time.
It turns out I don't even like the Whisper product, but I didn't
even know that until AFTER I built it as my first pro APK ever.
Lesson learned.
--- Synchronet 3.21a-Linux NewsLink 1.2