Working on Android build

This commit is contained in:
Vladislav Khorev 2026-07-18 17:46:05 +03:00
parent e773b51985
commit e5e3d7bb28
17 changed files with 93 additions and 24 deletions

View File

@ -1 +1 @@
### Перед запуском в папке ```app/jni/```(рядом с src) нужно создать три папки с исходниками библиотек ```libpng```, ```SDL```, ```zlib```
### Android version

View File

@ -9,7 +9,7 @@ else {
android {
if (buildAsApplication) {
namespace "org.libsdl.app"
namespace "fishrungames.shadowoverbishkek"
}
compileSdkVersion 37
defaultConfig {
@ -62,7 +62,7 @@ android {
libraryVariants.all { variant ->
variant.outputs.all { output ->
if (output.outputFileName != null && output.outputFileName.endsWith(".aar")) {
output.outputFileName = "org.libsdl.app.aar"
output.outputFileName = "fishrungames.shadowoverbishkek.aar"
}
}
}
@ -70,5 +70,6 @@ android {
}
dependencies {
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
}

View File

@ -16,18 +16,18 @@
# public *;
#}
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLInputConnection {
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLInputConnection {
void nativeCommitText(java.lang.String, int);
void nativeGenerateScancodeForUnichar(char);
}
-keep,includedescriptorclasses class org.libsdl.app.SDLActivity {
-keep,includedescriptorclasses class fishrungames.shadowoverbishkek.SDLActivity {
# for some reason these aren't compatible with allowoptimization modifier
boolean supportsRelativeMouse();
void setWindowStyle(boolean);
}
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLActivity {
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLActivity {
java.lang.String nativeGetHint(java.lang.String); # Java-side doesn't use this, so it gets minified, but C-side still tries to register it
boolean onNativeSoftReturnKey();
void onNativeKeyboardFocusLost();
@ -62,7 +62,7 @@
boolean showTextInput(int, int, int, int);
}
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager {
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.HIDDeviceManager {
boolean initialize(boolean, boolean);
boolean openDevice(int);
int sendOutputReport(int, byte[]);
@ -71,7 +71,7 @@
void closeDevice(int);
}
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLAudioManager {
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLAudioManager {
int[] getAudioOutputDevices();
int[] getAudioInputDevices();
int[] audioOpen(int, int, int, int, int);
@ -90,7 +90,7 @@
native void addAudioDevice(boolean, int);
}
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLControllerManager {
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLControllerManager {
void pollInputDevices();
void pollHapticDevices();
void hapticRun(int, float, int);

View File

@ -52,7 +52,7 @@
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<!-- Create a Java class extending SDLActivity and place it in a
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
directory under shadowoverbishkek/main/java matching the package, e.g. shadowoverbishkek/main/java/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below.
@ -62,14 +62,14 @@
<application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="true"
android:theme="@style/AppTheme"
android:theme="@style/Theme.App.Starting"
android:hardwareAccelerated="true" >
<!-- Example of setting SDL hints from AndroidManifest.xml:
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
-->
<activity android:name="SDLActivity"
<activity android:name=".ShadowOverBishkekActivity"
android:label="@string/app_name"
android:alwaysRetainTaskState="true"
android:launchMode="singleInstance"

View File

@ -0,0 +1,14 @@
package fishrungames.shadowoverbishkek;
import android.os.Bundle;
import androidx.core.splashscreen.SplashScreen;
import org.libsdl.app.SDLActivity;
public class ShadowOverBishkekActivity extends SDLActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.installSplashScreen(this);
super.onCreate(savedInstanceState);
}
}

BIN
proj-android/app/src/main/res/drawable/splash_icon.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">Тень над Бишкеком</string>
</resources>

View File

@ -1,3 +1,3 @@
<resources>
<string name="app_name">Game</string>
<string name="app_name">Shadow Over Bishkek</string>
</resources>

View File

@ -4,4 +4,13 @@
<style name="AppTheme" parent="android:Theme.NoTitleBar.Fullscreen">
<!-- Customize your theme here. -->
</style>
<!-- Тема для Splash Screen -->
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<!-- Черный фон -->
<item name="windowSplashScreenBackground">#000000</item>
<!-- Ваша картинка 512x512 -->
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<!-- Ссылка на основную тему, которая применится после загрузки -->
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
</resources>

View File

@ -18,9 +18,9 @@ android.r8.optimizedResourceShrinking=false
android.r8.strictFullModeForKeepRules=false
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
android.uniquePackageNames=false
android.useAndroidX=false
android.usesSdkInManifest.disallowed=false
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit

View File

@ -0,0 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73bcfb608d1fde9fb62e462f834a3299/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/846ee0d876d26a26f37aa1ce8de73224/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9482ddec596298c84656d31d16652665/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/39701d92e1756bb2f141eb67cd4c660e/redirect
toolchainVersion=21

View File

@ -388,6 +388,33 @@ namespace FRG
// --- Глобальные переменные логгера ---
namespace {
std::ofstream g_logFile;
#ifdef __ANDROID__
class AndroidLogBuffer : public std::streambuf {
private:
std::string buffer;
protected:
int overflow(int c) override {
if (c == '\n') {
__android_log_print(ANDROID_LOG_INFO, "ShadowOverBishkek", "%s", buffer.c_str());
buffer.clear();
}
else if (c != EOF) {
buffer += static_cast<char>(c);
}
return c;
}
int sync() override {
if (!buffer.empty()) {
__android_log_print(ANDROID_LOG_INFO, "ShadowOverBishkek", "%s", buffer.c_str());
buffer.clear();
}
return 0;
}
};
AndroidLogBuffer g_androidLogBuffer;
std::ostream g_androidStream(&g_androidLogBuffer);
#endif
std::unique_ptr<TeeBuffer> g_teeBuffer;
std::unique_ptr<std::ostream> g_teeStream;