Skip to content

Commit f092463

Browse files
committed
Update AGP, work on Android 14 support
1 parent 3f7b302 commit f092463

File tree

9 files changed

+90
-24
lines changed

9 files changed

+90
-24
lines changed

build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
plugins {
2-
id("com.android.library") version("7.4.2")
2+
id("com.android.library") version('8.9.1')
33
}
44

55
android {
6-
ndkVersion = "26.1.10909125"
7-
compileSdkVersion = "android-34"
6+
namespace 'pojlib'
7+
ndkVersion = "27.2.12479018"
8+
compileSdkVersion = "android-35"
89
defaultConfig {
910
minSdk 29
1011
multiDexEnabled true
1112
ndk.stl = "c++_shared"
12-
targetSdk 34
13+
targetSdk 35
1314
}
1415

1516
buildTypes {
@@ -27,13 +28,19 @@ android {
2728
}
2829
}
2930

30-
buildToolsVersion = "30.0.3"
31+
buildToolsVersion = '35.0.0'
3132
}
3233

3334
build {
3435
//finalizedBy(':wrapper:launcher:build')
3536
}
3637

38+
afterEvaluate {
39+
// Explicit dependencies for which the apk relies on
40+
tasks.mergeDebugAssets.dependsOn(":jre_lwjgl3glfw:jar")
41+
tasks.mergeReleaseAssets.dependsOn(":jre_lwjgl3glfw:jar")
42+
}
43+
3744
dependencies {
3845
// This dependency is exported to consumers, that is to say found on their compile classpath.
3946
api("org.apache.commons:commons-math3:3.6.1")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Tue Jun 04 16:34:57 EDT 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/main/AndroidManifest.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="pojlib.android">
1+
<manifest xmlns:tools="http://schemas.android.com/tools"
2+
xmlns:android="http://schemas.android.com/apk/res/android">
33
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4-
<application android:allowNativeHeapPointerTagging="false"/>
4+
<application android:allowNativeHeapPointerTagging="false"
5+
tools:targetApi="30">
6+
<activity
7+
android:name=".GameActivity"
8+
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|keyboard|navigation|uiMode"
9+
android:launchMode="singleTop"
10+
android:process=":game" />
11+
</application>
512
</manifest>
0 Bytes
Binary file not shown.

src/main/assets/lwjgl/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1738988056798
1+
1743052786968
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package pojlib;
2+
3+
import android.app.Service;
4+
import android.content.Intent;
5+
import android.os.Binder;
6+
import android.os.IBinder;
7+
8+
import androidx.annotation.Nullable;
9+
10+
public class GameActivity extends Service {
11+
private final Binder mLocalBinder = new Binder();
12+
13+
@Nullable
14+
@Override
15+
public IBinder onBind(Intent intent) {
16+
return mLocalBinder;
17+
}
18+
19+
@Override
20+
public int onStartCommand(Intent intent, int flags, int startId) {
21+
return START_NOT_STICKY;
22+
}
23+
24+
@Override
25+
public void onTaskRemoved(Intent rootIntent) {
26+
//At this point in time only the game runs and the user poofed the window, time to die
27+
stopSelf();
28+
android.os.Process.killProcess(android.os.Process.myPid());
29+
}
30+
}

src/main/java/pojlib/InstanceHandler.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package pojlib;
22

33
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.content.ServiceConnection;
46

57
import com.google.common.collect.Lists;
68

@@ -283,14 +285,14 @@ public static boolean delete(MinecraftInstances instances, MinecraftInstances.In
283285
return true;
284286
}
285287

288+
public static MinecraftAccount currentAcc;
289+
286290
public static void launchInstance(Activity activity, MinecraftAccount account, MinecraftInstances.Instance instance) {
287-
try {
288-
API.currentInstance = instance;
289-
JREUtils.redirectAndPrintJRELog();
290-
VLoader.setAndroidInitInfo(activity);
291-
JREUtils.launchJavaVM(activity, instance.generateLaunchArgs(account), instance);
292-
} catch (Throwable e) {
293-
e.printStackTrace();
294-
}
291+
API.currentInstance = instance;
292+
currentAcc = account;
293+
294+
Intent game = new Intent(activity, GameActivity.class);
295+
activity.startService(game);
296+
activity.bindService(game, (ServiceConnection) activity, 0);
295297
}
296298
}

src/main/java/pojlib/UnityPlayerActivity.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
import android.app.ActivityManager;
1313
import android.content.ClipData;
1414
import android.content.ClipboardManager;
15+
import android.content.ComponentName;
1516
import android.content.Context;
1617
import android.content.Intent;
18+
import android.content.ServiceConnection;
1719
import android.content.res.Configuration;
1820
import android.os.Build;
1921
import android.os.Bundle;
22+
import android.os.IBinder;
2023
import android.os.Process;
2124
import android.util.DisplayMetrics;
2225
import android.view.InputDevice;
@@ -48,11 +51,13 @@
4851
import pojlib.input.gamepad.Gamepad;
4952
import pojlib.util.Constants;
5053
import pojlib.util.FileUtil;
54+
import pojlib.util.JREUtils;
5155
import pojlib.util.Logger;
56+
import pojlib.util.VLoader;
5257
import pojlib.util.download.DownloadManager;
5358
import pojlib.util.download.DownloadUtils;
5459

55-
public class UnityPlayerActivity extends ActivityGroup implements IUnityPlayerLifecycleEvents, GrabListener
60+
public class UnityPlayerActivity extends ActivityGroup implements IUnityPlayerLifecycleEvents, GrabListener, ServiceConnection
5661
{
5762
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
5863
public static volatile ClipboardManager GLOBAL_CLIPBOARD;
@@ -99,6 +104,7 @@ protected String updateUnityCommandLineArguments(String cmdLine)
99104
updateWindowSize(this);
100105
GLOBAL_CLIPBOARD = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
101106

107+
/*
102108
mInputManager = new RemapperManager(this, new RemapperView.Builder(null)
103109
.remapA(true)
104110
.remapB(true)
@@ -116,6 +122,7 @@ protected String updateUnityCommandLineArguments(String cmdLine)
116122
.remapDpad(true));
117123
118124
CallbackBridge.nativeSetUseInputStackQueue(true);
125+
*/
119126
}
120127

121128
public static String installLWJGL(Activity activity) throws IOException {
@@ -222,7 +229,7 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
222229
if(Gamepad.isGamepadEvent(event)){
223230
if(mGamepad == null) createGamepad(event.getDevice());
224231

225-
mInputManager.handleMotionEventInput(this, event, mGamepad);
232+
//mInputManager.handleMotionEventInput(this, event, mGamepad);
226233
return true;
227234
}
228235

@@ -307,7 +314,7 @@ public boolean processKeyEvent(KeyEvent event) {
307314
if(Gamepad.isGamepadEvent(event)){
308315
if(mGamepad == null) createGamepad(event.getDevice());
309316

310-
mInputManager.handleKeyEventInput(this, event, mGamepad);
317+
// mInputManager.handleKeyEventInput(this, event, mGamepad);
311318
return true;
312319
}
313320

@@ -473,4 +480,20 @@ public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
473480
}
474481
@Override public boolean onTouchEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
475482
/*API12*/ public boolean onGenericMotionEvent(MotionEvent event) { return mUnityPlayer.injectEvent(event); }
483+
484+
@Override
485+
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
486+
try {
487+
JREUtils.redirectAndPrintJRELog();
488+
VLoader.setAndroidInitInfo(this);
489+
JREUtils.launchJavaVM(this, API.currentInstance.generateLaunchArgs(API.currentAcc), API.currentInstance);
490+
} catch (Throwable e) {
491+
e.printStackTrace();
492+
}
493+
}
494+
495+
@Override
496+
public void onServiceDisconnected(ComponentName componentName) {
497+
// noop
498+
}
476499
}

src/main/jniLibs/arm64-v8a/liblwjgl_openvr.so

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)