diff --git a/app/app/build.gradle b/app/app/build.gradle index 8880966d1bbce43ad46d40a4b6792499c11ec886..683f3595b14b84b2a6e6d2bf915bd4d94ff09197 100644 --- a/app/app/build.gradle +++ b/app/app/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' + id 'com.chaquo.python' } android { @@ -14,6 +15,15 @@ android { versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + ndk { + abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + } + + python { + version "3.9" + buildPython "python3.9" + } } buildTypes { @@ -45,4 +55,4 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' -} \ No newline at end of file +} diff --git a/app/app/src/main/python/main.py b/app/app/src/main/python/main.py new file mode 100644 index 0000000000000000000000000000000000000000..30d202f5caad9b53666bda5e0cfd4c8e92f39ffa --- /dev/null +++ b/app/app/src/main/python/main.py @@ -0,0 +1,14 @@ +from kivy.app import App +from kivy.uix.label import Label + +class MainApp(App): + def build(self): + label = Label(text='Hello from Kivy', + size_hint=(.5, .5), + pos_hint={'center_x': .5, 'center_y': .5}) + + return label + +if __name__ == '__main__': + app = MainApp() + app.run() diff --git a/app/build.gradle b/app/build.gradle index 7b9b67d4e8ddbfcb31ff7b8e674794ce268480f0..99e3fc48096b2166a7d3bbe81b5350c846a5a57a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,6 +3,7 @@ plugins { id 'com.android.application' version '7.2.1' apply false id 'com.android.library' version '7.2.1' apply false id 'org.jetbrains.kotlin.android' version '1.6.10' apply false + id 'com.chaquo.python' version '13.0.0' apply false } task clean(type: Delete) { diff --git a/flake.nix b/flake.nix index a43d6904711be75f0683fc0b4a6ba3d35e55205c..7866fe675aec453afdb209229a4e279be45f589b 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,9 @@ }; }; outputs = { self, nixpkgs, flake-utils, mach-nix-flake, buildozerSrc, pythonForAndroidSrc, ... }: - flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: let + flake-utils.lib.eachSystem [ + "x86_64-linux" + ] (system: let mach-nix = mach-nix-flake.lib.${system}; pkgs = import nixpkgs { @@ -68,10 +70,69 @@ androidComposition = pkgs.callPackage ./android.nix { inherit cmakeVersion; }; getBuildInputs = getInputs: xs: builtins.foldl' (accum: drv: (getInputs drv) ++ accum) [] xs; + + chaquopy-env = mach-nix.mkPython { + python = "python39"; + requirements = '' + chaquopy + ''; + }; in { + + packages.default = pkgs.androidenv.buildApp { + name = "PrivateStorage Mobile"; + src = ./app; + release = false; + + platformVersions = [ "27" ]; + includeNDK = false; + }; + + apps.emulator = { + type = "app"; + program = let + emulator = pkgs.androidenv.emulateApp { + name = "PrivateStorage Mobile"; + platformVersion = "27"; + abiVersion = "x86_64"; + systemImageType = "default"; + app = ./app/app/build/outputs/apk/debug/app-debug.apk; + package = "MyApp"; + activity = "MainActivity"; + }; + in + "${emulator}/bin/emulate-it???"; + }; + devShells.gradle = pkgs.mkShell rec { + name = "nix-native"; + version = "2022.11.09"; + + ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk"; + ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle"; + + buildInputs = with pkgs; [ + + # XXXX + # gradle finds an aapk2 from some random tgz it downloads from internet instead of from our ANDROIDSDK! GREAT!!!!!!!!!!11111 + # + # Fix the one it downloads, if it didn't already root you, with: + # + # patchelf --set-interpreter <correct ld.so> ~/.gradle/<...path to aapt2> + + gradle + ant + # openjdk8 + android-studio + android-tools + python39 + ]; + }; + + devShells.default = self.devShells.${system}.gradle; + # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/android.section.md # is a good reference for this stuff. - devShells.default = pkgs.mkShell rec { + devShells.kivy = pkgs.mkShell rec { name = "ps-mobile"; version = "2022.10.21"; @@ -86,6 +147,7 @@ buildInputs = with pkgs; [ android-studio + android-tools kivy-env # Kivy and python-for-android depend on: