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.sh
More file actions
197 lines (153 loc) · 6 KB
/
Copy pathbuild.sh
File metadata and controls
197 lines (153 loc) · 6 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
#!/bin/bash
# =============================================================================
# KnightLauncher Android Build Script for Linux
# =============================================================================
# This script builds the KnightLauncher Android APK.
# Requirements:
# - JDK 21 or 25 (Temurin recommended)
# - Git with submodules cloned
# - Internet connection (for downloading JRE artifacts)
# - curl, unzip
# =============================================================================
set -e # Exit on error
# Clear console
clear
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print colored messages
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Configuration
ASSETS_DIR="app_pojavlauncher/src/main/assets/components/jre-25"
# =============================================================================
# Functions
# =============================================================================
check_requirements() {
info "Checking requirements..."
# Use JAVA_HOME if set
if [[ -n "$JAVA_HOME" ]]; then
info "JAVA_HOME is set to: $JAVA_HOME"
export PATH="$JAVA_HOME/bin:$PATH"
fi
# Check Java version
if ! command -v java &> /dev/null; then
error "Java is not installed. Please install JDK 21 or 25 (Temurin recommended).
Download from: https://adoptium.net/temurin/releases/"
fi
JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2 | cut -d'.' -f1)
info "Java version detected: $JAVA_VERSION"
if [[ "$JAVA_VERSION" != "21" && "$JAVA_VERSION" != "25" ]]; then
echo ""
error "JDK 21 or 25 is REQUIRED but found JDK $JAVA_VERSION.
KnightLauncher Android requires JDK 21 or 25 to build.
Solutions:
1. Install JDK 21 or 25 Temurin from: https://adoptium.net/temurin/releases/
2. Set JAVA_HOME to your JDK installation:
export JAVA_HOME=/path/to/jdk-21 or export JAVA_HOME=/path/to/jdk-25
3. Or run this script from a shell with JDK 21 or 25 in PATH"
fi
success "JDK $JAVA_VERSION detected."
# Enable native access for JDK 25+ (restricted methods are blocked by default)
if [[ "$JAVA_VERSION" -ge 25 ]]; then
info "JDK 25+ detected, enabling native access for Gradle and subprocesses..."
export GRADLE_OPTS="${GRADLE_OPTS} --enable-native-access=ALL-UNNAMED"
export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} --enable-native-access=ALL-UNNAMED"
fi
# Check curl
if ! command -v curl &> /dev/null; then
error "curl is not installed. Please install curl."
fi
# Check unzip
if ! command -v unzip &> /dev/null; then
error "unzip is not installed. Please install unzip."
fi
success "All requirements met."
}
check_jre() {
info "Checking JRE 25 component..."
# Create directory if needed
mkdir -p "$ASSETS_DIR"
# Check if both required JRE files exist
local jre_arm="$ASSETS_DIR/bin-arm.tar.xz"
local jre_arm64="$ASSETS_DIR/bin-arm64.tar.xz"
if [[ -f "$jre_arm" && -f "$jre_arm64" ]]; then
success "JRE 25 component found."
else
echo ""
error "JRE 25 component is missing!
Required files:
- bin-arm.tar.xz
- bin-arm64.tar.xz
Please manually download jre25-multiarch from:
https://github.com/FCL-Team/Android-OpenJDK-Build/actions?query=branch%3ABuild_JRE_25
After downloading, extract the contents to:
$ASSETS_DIR
Then run this script again."
fi
}
update_language_list() {
info "Updating language list..."
if [[ -f "scripts/languagelist_updater.sh" ]]; then
chmod +x scripts/languagelist_updater.sh
bash scripts/languagelist_updater.sh
success "Language list updated."
else
warning "Language list updater script not found. Skipping."
fi
}
patch_mobileglues() {
info "Patching MobileGlues for ARM-only build..."
# Check if already patched
if grep -q "abiFilters" MobileGlues/build.gradle.kts 2>/dev/null; then
info "MobileGlues already patched for ARM-only build. Skipping."
return 0
fi
# Skip x86/x86_64 builds (only ARM devices are supported)
sed -i 's/ndkVersion = "27.3.13750724"/ndkVersion = "27.3.13750724"\n ndk {\n \/\/ Only build for ARM architectures (skip x86\/x86_64 which are for emulators)\n abiFilters += listOf("arm64-v8a", "armeabi-v7a")\n }/' MobileGlues/build.gradle.kts
success "MobileGlues patched for ARM-only build."
}
build_glfw_stub() {
info "Building GLFW stub (jre_lwjgl3glfw)..."
./gradlew :jre_lwjgl3glfw:build --build-cache
success "GLFW stub built."
}
build_apk() {
info "Building KnightLauncher APK..."
./gradlew :app_pojavlauncher:assembleRelease --build-cache
# Create output directory and copy APK
mkdir -p out
cp app_pojavlauncher/build/outputs/apk/release/app_pojavlauncher-release.apk build/KnightLauncher.apk
success "APK built successfully!"
success "Output: $(realpath build/KnightLauncher.apk)"
}
# =============================================================================
# Main
# =============================================================================
main() {
echo ""
echo "=============================================="
echo " KnightLauncher Android Build Script"
echo "=============================================="
echo ""
check_requirements
check_jre
update_language_list
patch_mobileglues
build_glfw_stub
build_apk
echo ""
success "Build completed successfully!"
echo ""
echo "The APK is located at: build/KnightLauncher.apk"
echo ""
}
main "$@"