Skip to content

Commit 6a67735

Browse files
authored
Add Android Studio project for OpenGL renderer integration (#78) (#79)
1 parent 5e84235 commit 6a67735

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1156
-0
lines changed

.github/workflows/android.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Android
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'android/**'
8+
- '.github/workflows/android.yml'
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- 'android/**'
13+
- '.github/workflows/android.yml'
14+
workflow_dispatch:
15+
16+
jobs:
17+
build:
18+
name: Debug build
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
lfs: true
25+
26+
- name: Set up Java 21
27+
uses: actions/setup-java@v4
28+
with:
29+
java-version: '21'
30+
distribution: 'temurin'
31+
32+
- name: Install NDK and CMake
33+
run: |
34+
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager \
35+
"ndk;30.0.14904198" \
36+
"cmake;3.22.1"
37+
38+
- name: Cache Gradle
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
~/.gradle/caches
43+
~/.gradle/wrapper
44+
key: gradle-${{ hashFiles('android/**/*.gradle*', 'android/**/gradle-wrapper.properties') }}
45+
restore-keys: gradle-
46+
47+
- name: Cache NDK build artifacts
48+
uses: actions/cache@v4
49+
with:
50+
path: android/app/.cxx
51+
key: ndk-${{ runner.os }}-${{ hashFiles('android/app/src/main/cpp/CMakeLists.txt') }}
52+
restore-keys: ndk-${{ runner.os }}-
53+
54+
- name: Build
55+
working-directory: android
56+
run: ./gradlew assembleDebug
57+
58+
- name: Upload APK
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: hawkeye-android-debug
62+
path: android/app/build/outputs/apk/debug/app-debug.apk
63+
retention-days: 7

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ build-debug/
44
build-release/
55
.dmux/
66
.dmux-hooks/
7+
8+
# Android
9+
android/local.properties
10+
android/.gradle/
11+
android/app/build/
12+
android/app/.cxx/
13+
android/build/
14+
android/.idea/workspace.xml
15+
android/.claude/
16+
android/.idea/*

android/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

android/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Hawkeye Android
2+
3+
Android port of the Hawkeye 3D renderer, running the desktop C/Raylib scene natively on Android via NativeActivity and OpenGL ES 3.0.
4+
5+
## Architecture
6+
7+
The app has no Java/Kotlin logic beyond the manifest declaration. `NativeActivity` loads `libhawkeye.so`, which runs a standard C `main()` entry point via Raylib's Android platform backend.
8+
9+
```
10+
android/
11+
├── app/src/main/
12+
│ ├── AndroidManifest.xml — declares NativeActivity, requires OpenGL ES 3.0
13+
│ ├── assets/ — all symlinks into the parent Hawkeye project
14+
│ │ ├── fonts -> ../../../../fonts
15+
│ │ ├── models -> ../../../../models
16+
│ │ ├── shaders -> ../../../../shaders
17+
│ │ └── themes -> ../../../../themes
18+
│ └── cpp/
19+
│ ├── CMakeLists.txt — fetches Raylib 5.5, compiles rendering subset
20+
│ └── android_main.c — entry point: scene_init + vehicle_init + render loop
21+
```
22+
23+
The Hawkeye source files compiled in are: `scene.c`, `vehicle.c`, `asset_path.c`, `theme.c`, `ortho_panel.c`. MAVLink, ULog, HUD, and replay code are excluded.
24+
25+
## Shader Compatibility
26+
27+
The original shaders use `#version 330` (desktop OpenGL). On Android they are patched at load time via Raylib's `SetLoadFileTextCallback`:
28+
29+
- `#version 330``#version 300 es`
30+
- `precision mediump float;` is injected into fragment shaders
31+
32+
No shader copies are kept in the Android project — the `shaders/` asset dir is a symlink to the originals.
33+
34+
## Environment Setup
35+
36+
If you haven't done Android development before, here's what you need:
37+
38+
### 1. Install Android Studio
39+
40+
Download and install [Android Studio](https://developer.android.com/studio) for your platform (macOS, Linux, or Windows). The installer includes the Android SDK and the SDK Manager.
41+
42+
### 2. Install the NDK and CMake
43+
44+
Open Android Studio, go to **Settings → Languages & Frameworks → Android SDK → SDK Tools**, check:
45+
46+
- **NDK (Side by side)** — install version `30.0.14904198`
47+
- **CMake** — install version `3.22.1`
48+
49+
Click **Apply**.
50+
51+
Alternatively, from the command line (replace `$ANDROID_SDK_ROOT` with your SDK path — typically `~/Library/Android/sdk` on macOS or `~/Android/Sdk` on Linux):
52+
53+
```bash
54+
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "ndk;30.0.14904198" "cmake;3.22.1"
55+
```
56+
57+
### 3. Open the project
58+
59+
Open the `android/` directory in Android Studio. Gradle will sync automatically and download any remaining dependencies.
60+
61+
### Note on symlinks
62+
63+
The `assets/` directory uses symlinks into the parent repo (fonts, models, shaders, themes). These work on macOS and Linux out of the box. On Windows, either enable [Developer Mode](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) before cloning or use WSL.
64+
65+
## Requirements
66+
67+
- Android SDK (API 29+)
68+
- NDK 30.0.14904198
69+
- CMake 3.22+
70+
- A device or emulator with OpenGL ES 3.0 support
71+
72+
## Building
73+
74+
```bash
75+
./gradlew assembleDebug
76+
```
77+
78+
Raylib 5.5 is fetched automatically by CMake on the first build. Built ABIs: `arm64-v8a`, `x86_64`.
79+
80+
## Deploying
81+
82+
```bash
83+
adb install -r app/build/outputs/apk/debug/app-debug.apk
84+
adb shell am start -n com.px4.hawkeye.android/android.app.NativeActivity
85+
```
86+

android/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

android/app/build.gradle.kts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
}
4+
5+
android {
6+
namespace = "com.px4.hawkeye.android"
7+
compileSdk {
8+
version = release(36) {
9+
minorApiLevel = 1
10+
}
11+
}
12+
13+
ndkVersion = "30.0.14904198"
14+
15+
externalNativeBuild {
16+
cmake {
17+
path = file("src/main/cpp/CMakeLists.txt")
18+
version = "3.22.1"
19+
}
20+
}
21+
22+
defaultConfig {
23+
applicationId = "com.px4.hawkeye.android"
24+
minSdk = 29
25+
targetSdk = 36
26+
versionCode = 1
27+
versionName = "1.0"
28+
29+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
30+
31+
externalNativeBuild {
32+
cmake {
33+
abiFilters += listOf("arm64-v8a", "x86_64")
34+
}
35+
}
36+
}
37+
38+
buildTypes {
39+
release {
40+
isMinifyEnabled = false
41+
proguardFiles(
42+
getDefaultProguardFile("proguard-android-optimize.txt"),
43+
"proguard-rules.pro"
44+
)
45+
}
46+
}
47+
compileOptions {
48+
sourceCompatibility = JavaVersion.VERSION_11
49+
targetCompatibility = JavaVersion.VERSION_11
50+
}
51+
}
52+
53+
dependencies {
54+
implementation(libs.androidx.core.ktx)
55+
implementation(libs.androidx.appcompat)
56+
implementation(libs.material)
57+
testImplementation(libs.junit)
58+
androidTestImplementation(libs.androidx.junit)
59+
androidTestImplementation(libs.androidx.espresso.core)
60+
}

android/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:dataExtractionRules="@xml/data_extraction_rules"
10+
android:fullBackupContent="@xml/backup_rules"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/Theme.HawkeyeAndroid">
16+
17+
<activity
18+
android:name="android.app.NativeActivity"
19+
android:exported="true"
20+
android:screenOrientation="landscape"
21+
android:configChanges="orientation|screenSize|keyboardHidden">
22+
23+
<meta-data
24+
android:name="android.app.lib_name"
25+
android:value="hawkeye" />
26+
27+
<intent-filter>
28+
<action android:name="android.intent.action.MAIN" />
29+
<category android:name="android.intent.category.LAUNCHER" />
30+
</intent-filter>
31+
</activity>
32+
33+
</application>
34+
35+
</manifest>

android/app/src/main/assets/fonts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../fonts

0 commit comments

Comments
 (0)