Skip to content

Commit 856c5b3

Browse files
committed
Fix singleplayer crashing by downgrading to JRE-17
1 parent 3c7d42f commit 856c5b3

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

lib/src/main/java/pojlib/UnityPlayerActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ protected String updateUnityCommandLineArguments(String cmdLine)
5353
mUnityPlayer = new UnityPlayer(this, this);
5454
setContentView(mUnityPlayer);
5555
mUnityPlayer.requestFocus();
56-
File zip = new File(this.getFilesDir() + "/runtimes/JRE-21.zip");
56+
File zip = new File(this.getFilesDir() + "/runtimes/JRE-17.zip");
5757
if(!zip.exists()) {
5858
try {
59-
FileUtils.writeByteArrayToFile(zip, FileUtil.loadFromAssetToByte(this, "JRE-21.zip"));
59+
FileUtils.writeByteArrayToFile(zip, FileUtil.loadFromAssetToByte(this, "JRE-17.zip"));
6060
byte[] buffer = new byte[1024];
6161
ZipInputStream zis = new ZipInputStream(Files.newInputStream(zip.toPath()));
6262
ZipEntry zipEntry = zis.getNextEntry();
6363
while (zipEntry != null) {
64-
File newFile = newFile(new File(this.getFilesDir() + "/runtimes/JRE-21"), zipEntry);
64+
File newFile = newFile(new File(this.getFilesDir() + "/runtimes/JRE-17"), zipEntry);
6565
if (zipEntry.isDirectory()) {
6666
if (!newFile.isDirectory() && !newFile.mkdirs()) {
6767
throw new IOException("Failed to create directory " + newFile);

lib/src/main/java/pojlib/util/JREUtils.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ public void run() {
131131
public static void relocateLibPath(final Context ctx) {
132132
sNativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
133133

134-
LD_LIBRARY_PATH = ctx.getFilesDir() + "/runtimes/JRE-21/bin" + "/lib64/jli:" + ctx.getFilesDir() + "/runtimes/JRE-21/lib:" +
134+
LD_LIBRARY_PATH = ctx.getFilesDir() + "/runtimes/JRE-17/bin" + "/lib64/jli:" + ctx.getFilesDir() + "/runtimes/JRE-17/lib:" +
135135
"/system/lib64:lib64/vendor/lib64:/vendor/lib64/hw:" +
136136
sNativeLibDir;
137137
}
138138

139139
public static void setJavaEnvironment(Activity activity) throws Throwable {
140140
Map<String, String> envMap = new ArrayMap<>();
141141
envMap.put("POJAV_NATIVEDIR", activity.getApplicationInfo().nativeLibraryDir);
142-
envMap.put("JAVA_HOME", activity.getFilesDir() + "/runtimes/JRE-21");
142+
envMap.put("JAVA_HOME", activity.getFilesDir() + "/runtimes/JRE-17");
143143
envMap.put("HOME", Constants.MC_DIR);
144144
envMap.put("TMPDIR", activity.getCacheDir().getAbsolutePath());
145145
envMap.put("LIBGL_MIPMAP", "3");
@@ -150,7 +150,7 @@ public static void setJavaEnvironment(Activity activity) throws Throwable {
150150
envMap.put("POJAV_RENDERER", "vulkan_zink");
151151

152152
envMap.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH);
153-
envMap.put("PATH", activity.getFilesDir() + "/runtimes/JRE-21/bin:" + Os.getenv("PATH"));
153+
envMap.put("PATH", activity.getFilesDir() + "/runtimes/JRE-17/bin:" + Os.getenv("PATH"));
154154

155155
envMap.put("LIBGL_GLES", "/system/lib64/libGLESv2.so");
156156
envMap.put("LIBGL_EGL", "/system/lib64/libEGL.so");
@@ -172,8 +172,8 @@ public static void setJavaEnvironment(Activity activity) throws Throwable {
172172
Os.setenv(env.getKey(), env.getValue(), true);
173173
}
174174

175-
File serverFile = new File(activity.getFilesDir() + "/runtimes/JRE-21/lib/server/libjvm.so");
176-
jvmLibraryPath = activity.getFilesDir() + "/runtimes/JRE-21/lib/" + (serverFile.exists() ? "server" : "client");
175+
File serverFile = new File(activity.getFilesDir() + "/runtimes/JRE-17/lib/server/libjvm.so");
176+
jvmLibraryPath = activity.getFilesDir() + "/runtimes/JRE-17/lib/" + (serverFile.exists() ? "server" : "client");
177177
Log.d("DynamicLoader","Base LD_LIBRARY_PATH: "+LD_LIBRARY_PATH);
178178
Log.d("DynamicLoader","Internal LD_LIBRARY_PATH: "+jvmLibraryPath+":"+LD_LIBRARY_PATH);
179179
setLdLibraryPath(jvmLibraryPath+":"+LD_LIBRARY_PATH);
@@ -206,7 +206,7 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
206206
userArgs.addAll(JVMArgs);
207207
System.out.println(JVMArgs);
208208

209-
runtimeDir = activity.getFilesDir() + "/runtimes/JRE-21";
209+
runtimeDir = activity.getFilesDir() + "/runtimes/JRE-17";
210210

211211
initJavaRuntime();
212212
chdir(Constants.MC_DIR);
@@ -225,7 +225,7 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
225225
*/
226226
public static List<String> getJavaArgs(Context ctx) {
227227
return new ArrayList<>(Arrays.asList(
228-
"-Djava.home=" + new File(ctx.getFilesDir(), "runtimes/JRE-21"),
228+
"-Djava.home=" + new File(ctx.getFilesDir(), "runtimes/JRE-17"),
229229
"-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath(),
230230
"-Duser.home=" + Constants.MC_DIR,
231231
"-Duser.language=" + System.getProperty("user.language"),

0 commit comments

Comments
 (0)