This repository was archived by the owner on May 25, 2026. It is now read-only.
forked from AngelAuraMC/Amethyst-Android
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.bat
More file actions
219 lines (176 loc) · 6.57 KB
/
Copy pathbuild.bat
File metadata and controls
219 lines (176 loc) · 6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
@echo off
setlocal EnableDelayedExpansion
:: =============================================================================
:: KnightLauncher Android Build Script for Windows
:: =============================================================================
:: This script builds the KnightLauncher Android APK.
:: Requirements:
:: - JDK 21 or 25 (Temurin recommended)
:: - Git with submodules cloned
:: - Internet connection (for downloading JRE artifacts)
:: - PowerShell (for downloading files)
:: =============================================================================
title KnightLauncher Android Build
cls
:: Get script directory and navigate there
set "SCRIPT_DIR=%~dp0"
cd /d "%SCRIPT_DIR%"
:: Configuration
set "ASSETS_DIR=app_pojavlauncher\src\main\assets\components\jre-25"
echo.
echo ==============================================
echo KnightLauncher Android Build Script
echo ==============================================
echo.
:: =============================================================================
:: Check Requirements
:: =============================================================================
echo [INFO] Checking requirements...
:: Check JAVA_HOME first (prefer explicit JDK 21 or 25 path)
if defined JAVA_HOME (
echo [INFO] JAVA_HOME is set to: %JAVA_HOME%
set "PATH=%JAVA_HOME%\bin;%PATH%"
)
:: Check Java
where java >nul 2>&1
if errorlevel 1 (
echo [ERROR] Java is not installed. Please install JDK 21 or 25 Temurin.
echo [INFO] Download from: https://adoptium.net/temurin/releases/
goto :error_exit
)
:: Check Java version - require Java 21 or 25
echo [INFO] Checking Java version...
for /f "tokens=3" %%v in ('java -version 2^>^&1 ^| findstr /i "version"') do (
set "JAVA_VER_STRING=%%~v"
)
:: Extract major version (handles "21.0.x" or "25.0.x" format)
for /f "tokens=1 delims=." %%m in ("!JAVA_VER_STRING!") do (
set "JAVA_MAJOR=%%m"
)
echo [INFO] Java version detected: !JAVA_VER_STRING! (major: !JAVA_MAJOR!)
if not "!JAVA_MAJOR!"=="21" if not "!JAVA_MAJOR!"=="25" (
echo.
echo [ERROR] JDK 21 or 25 is REQUIRED but found JDK !JAVA_MAJOR!.
echo [ERROR] KnightLauncher Android requires JDK 21 or 25 to build.
echo.
echo [INFO] Solutions:
echo 1. Install JDK 21 or 25 Temurin from: https://adoptium.net/temurin/releases/
echo 2. Set JAVA_HOME to your JDK installation:
echo set JAVA_HOME=C:\path\to\jdk-21 or set JAVA_HOME=C:\path\to\jdk-25
echo 3. Or run this script from a shell with JDK 21 or 25 in PATH
echo.
goto :error_exit
)
echo [SUCCESS] JDK !JAVA_MAJOR! detected.
:: Enable native access for JDK 25+ (restricted methods are blocked by default)
if !JAVA_MAJOR! GEQ 25 (
echo [INFO] JDK 25+ detected, enabling native access for Gradle and subprocesses...
set "GRADLE_OPTS=%GRADLE_OPTS% --enable-native-access=ALL-UNNAMED"
set "JAVA_TOOL_OPTIONS=%JAVA_TOOL_OPTIONS% --enable-native-access=ALL-UNNAMED"
)
echo.
:: Check PowerShell
where powershell >nul 2>&1
if errorlevel 1 (
echo [ERROR] PowerShell is not installed. Required for downloading files.
goto :error_exit
)
echo [SUCCESS] All requirements met.
echo.
:: =============================================================================
:: Check JRE Components
:: =============================================================================
echo [INFO] Checking JRE 25 component...
:: Create directory if needed
if not exist "%ASSETS_DIR%" mkdir "%ASSETS_DIR%"
:: Check if both required JRE files exist
set "JRE_ARM=%ASSETS_DIR%\bin-arm.tar.xz"
set "JRE_ARM64=%ASSETS_DIR%\bin-arm64.tar.xz"
if exist "!JRE_ARM!" if exist "!JRE_ARM64!" (
echo [SUCCESS] JRE 25 component found.
goto :jre_ok
)
echo.
echo [ERROR] JRE 25 component is missing!
echo.
echo [INFO] Required files:
echo - bin-arm.tar.xz
echo - bin-arm64.tar.xz
echo.
echo [INFO] Please manually download jre25-multiarch from:
echo https://github.com/FCL-Team/Android-OpenJDK-Build/actions?query=branch%%3ABuild_JRE_25
echo.
echo [INFO] After downloading, extract the contents to:
echo %ASSETS_DIR%
echo.
echo [INFO] Then run this script again.
echo.
goto :error_exit
:jre_ok
echo.
:: =============================================================================
:: Update Language List
:: =============================================================================
echo [INFO] Updating language list...
if exist "scripts\languagelist_updater.bat" (
call scripts\languagelist_updater.bat
if errorlevel 1 (
echo [WARNING] Language list updater had issues but continuing...
) else (
echo [SUCCESS] Language list updated.
)
) else (
echo [WARNING] Language list updater script not found. Skipping.
)
echo.
:: =============================================================================
:: Patch MobileGlues for ARM-only build
:: =============================================================================
echo [INFO] Patching MobileGlues for ARM-only build...
:: Use external PowerShell script to avoid CMD escaping issues
powershell -ExecutionPolicy Bypass -File "scripts\patch_mobileglues.ps1"
echo.
:: =============================================================================
:: Build GLFW Stub
:: =============================================================================
echo [INFO] Building GLFW stub jre_lwjgl3glfw...
call gradlew.bat :jre_lwjgl3glfw:build --build-cache
if errorlevel 1 (
echo [ERROR] Failed to build GLFW stub.
goto :error_exit
)
echo [SUCCESS] GLFW stub built.
echo.
:: =============================================================================
:: Build APK
:: =============================================================================
echo [INFO] Building KnightLauncher APK...
call gradlew.bat :app_pojavlauncher:assembleRelease --build-cache
if errorlevel 1 (
echo [ERROR] Failed to build APK.
goto :error_exit
)
:: Create output directory and copy APK
if not exist "out" mkdir "out"
copy /y "app_pojavlauncher\build\outputs\apk\release\app_pojavlauncher-release.apk" "build\KnightLauncher.apk" >nul
echo [SUCCESS] APK built successfully!
echo.
echo ==============================================
echo Build completed successfully!
echo ==============================================
echo.
echo The APK is located at: %SCRIPT_DIR%build\KnightLauncher.apk
echo.
goto :success_exit
:: =============================================================================
:: Exit handlers
:: =============================================================================
:error_exit
echo.
echo [ERROR] Build failed!
echo.
pause
exit /b 1
:success_exit
pause
exit /b 0