diff --git a/android/app/CMakeLists.txt b/android/app/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..bebde8a --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,67 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "com.critterfolio.app" + compileSdk = 34 + ndkVersion = "26.3.11579264" + + defaultConfig { + applicationId = "com.critterfolio.app" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "0.1.0" + + ndk { + abiFilters += listOf("arm64-v8a") + } + + externalNativeBuild { + cmake { + arguments += "-DANDROID_STL=c++_shared" + cppFlags += "-std=c++17" + } + } + } + + buildFeatures { + prefab = true + } + + externalNativeBuild { + cmake { + path = file("CMakeLists.txt") + version = "3.22.1" + } + } + + sourceSets { + getByName("main") { + assets.srcDirs("../../assets") + } + } + + buildTypes { + release { + isMinifyEnabled = false + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + packaging { + jniLibs { + useLegacyPackaging = true + } + } +} + +dependencies { + implementation(files("libs/SDL3-3.4.14.aar")) + implementation(files("libs/SDL3_image-3.4.4.aar")) +} \ No newline at end of file diff --git a/android/app/libs/SDL3-3.4.14.aar b/android/app/libs/SDL3-3.4.14.aar new file mode 100644 index 0000000..9b9d06f Binary files /dev/null and b/android/app/libs/SDL3-3.4.14.aar differ diff --git a/android/app/libs/SDL3_image-3.4.4.aar b/android/app/libs/SDL3_image-3.4.4.aar new file mode 100644 index 0000000..0e4ad71 Binary files /dev/null and b/android/app/libs/SDL3_image-3.4.4.aar differ diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..bd03416 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/java/com/critterfolio/app/MainActivity.java b/android/app/src/main/java/com/critterfolio/app/MainActivity.java new file mode 100644 index 0000000..9b0ce63 --- /dev/null +++ b/android/app/src/main/java/com/critterfolio/app/MainActivity.java @@ -0,0 +1,13 @@ +package com.critterfolio.app; + +import org.libsdl.app.SDLActivity; + +public class MainActivity extends SDLActivity { + @Override + protected String[] getLibraries() { + return new String[] { + "SDL3", + "critterfolio" + }; + } +} \ No newline at end of file diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..0122acb --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("com.android.application") version "8.5.2" apply false +} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..987f4bd --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx2048m +android.useAndroidX=true \ No newline at end of file diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..b525a81 --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "critterfolio" +include(":app") \ No newline at end of file diff --git a/flake.nix b/flake.nix index 4036ee2..3b915d0 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,13 @@ outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { inherit system; }; + pkgs = import nixpkgs { + inherit system; + config = { + allowUnfree = true; + android_sdk.accept_license = true; + }; + }; rmlui = pkgs.stdenv.mkDerivation rec { pname = "rmlui"; @@ -66,10 +72,31 @@ sqlitecpp toml11 ]; + + ndkVersion = "26.3.11579264"; + + androidComposition = pkgs.androidenv.composeAndroidPackages { + platformVersions = [ "34" ]; + buildToolsVersions = [ "34.0.0" ]; + includeNDK = true; + ndkVersions = [ ndkVersion ]; + abiVersions = [ "arm64-v8a" ]; + includeEmulator = false; + }; + + androidSdkRoot = "${androidComposition.androidsdk}/libexec/android-sdk"; + androidNdkRoot = "${androidSdkRoot}/ndk/${ndkVersion}"; + + androidDeps = [ + androidComposition.androidsdk + pkgs.gradle + pkgs.jdk17 + pkgs.ninja + ]; in { devShells.default = pkgs.mkShell { - nativeBuildInputs = buildDeps; + nativeBuildInputs = buildDeps ++ androidDeps; buildInputs = runtimeDeps; shellHook = '' @@ -77,7 +104,12 @@ export LIBRARY_PATH="${pkgs.libGL}/lib:${rmlui}/lib" export LD_LIBRARY_PATH="$LIBRARY_PATH:$LD_LIBRARY_PATH" - echo "Env ready" + export ANDROID_HOME="${androidSdkRoot}" + export ANDROID_SDK_ROOT="${androidSdkRoot}" + export ANDROID_NDK_HOME="${androidNdkRoot}" + export ANDROID_NDK_ROOT="${androidNdkRoot}" + + echo "Env ready (desktop + Android NDK ${ndkVersion}, arm64-v8a)" ''; };