Giter VIP home page Giter VIP logo

zigandroidtemplate's Introduction

NOTICE OF ARCHIVAL

https://github.com/slimsag/ZigAndroidTemplate does everything this fork was meant to do and does it better.

Android Apps in Zig

Project banner

This repository contains multiple examples of creating a minimal Android app in Zig.

Examples

There are 4 different examples. The examples have no dependencies on C code except for the android libraries, so they can be considered pure Zig apps.

To select which example to build and run, pass the example flag (e.g. -Dexample=egl). Valid values for the example flag are egl, minimal, textview, and invocationhandler.

We're running a CI that will verify the build for Windows, macOS and Linux:

CI

Minimal

examples/minimal includes just enough code to get the app running.

EGL

examples/egl/ initializes OpenGL and renders a color cycle. Touchscreen events will activate a sine wave synth and be displayed as small circles beneath the fingers that will fade as soon as no event for the same finger will happen again.

The code contains some commented examples on how to interface with the JNI to use advanced features of the ANativeActivity.

Textview

examples/textview/ creates a Textview component with Android's built-in UI to display "Hello, World!".

InvocationHandler

examples/invocationhandler builds on the textview example. It shows how to pass a callback to the JNI by creating a button component that reacts to being pressed.

Presentation

There is a FOSDEM Talk you can watch here:

Since the time of recording ZigAndroidTemplate has changed in some major ways.

What's missing

  • Configuration management example
  • Save/load app state example

Requirements & Build

You need the Android SDK installed together with the Android NDK.

You also need adb and a Java SDK installed (required for jarsigner).

Now you need to generate yourself a keystore to sign your apps. For debugging purposes, the build script contains a helper. Just invoke zig build keystore to generate yourself a debug keystore that can be used with later build invocations.

Note that the build file might ask you to configure some paths. Do as requested and just run the build again, it should work then.

If all of the above is done, you should be able to build the app by running zig build.

There are convenience options with zig build push (installs the app on a connected phone) and zig build run (which installs, then runs the app).

Quick Start

Install the sdkmanager and invoke the following command line:

# Android Platforms for your target Android version
# Min version: Android 5
sdkmanager --install "platforms;android-21"
# you can install other versions as well
# remember to set it like `zig build -Dandroid=android99`

sdkmanager --install "build-tools;33.0.1"
sdkmanager --install "ndk;25.1.8937393"
zig build keystore install run

This should build an APK and install it on your connected phone if possible.

Getting started

Check out the build.zig to see how to build a new android app. The examples folder has multiple examples for making minimal android apps.

Credits

Huge thanks to @cnlohr to create rawdrawandroid and making this project possible!

zigandroidtemplate's People

Contributors

desttinghim avatar ikskuh avatar zenith391 avatar iacore avatar jmrico01 avatar ilidemi avatar strandedsoftwaredeveloper avatar spexguy avatar deecellar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.