mirror of
https://github.com/IllusionMan1212/android-native-example-odin.git
synced 2026-10-24 10:12:33 +00:00
Compare commits
5
Commits
a7dca34510
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c657f7abc4
|
||
|
|
147b0ec325
|
||
|
|
b643b0b3c2
|
||
|
|
ff674affbd
|
||
|
|
135171813f
|
@@ -4,10 +4,12 @@ This requires that you write some basic bindings to the Android NDK (or use mine
|
||||
|
||||
# Building
|
||||
|
||||
First you must adjust `build.sh` and `launch.sh` to have correct paths to Android SDK, Android NDK and the Jetbrains RT.
|
||||
Then set `APK` variable to the desired apk package name. Use Android SDK to install build-tools and platform SDK.
|
||||
### Prerequisites
|
||||
- The Android SDK must be installed and the appropriate Odin environment variables must be set.
|
||||
- The `keytool` binary must be in your PATH
|
||||
|
||||
Now you can use `build.sh` to build and install the app, and `launch.sh` to run the application:
|
||||
### Steps
|
||||
Run `build.sh` to build and install the app, and `launch.sh` to run the application:
|
||||
|
||||
# License
|
||||
The code is licensed under the Unlicense license. I do not own the app icon (Odin logo). The logo copyright is owned by [GingerBill](https://github.com/gingerbill)
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
## TODO: handle different ABIs, currently only builds for arm64
|
||||
|
||||
ANDROID_JBR=/home/illusion/android-studio/jbr
|
||||
|
||||
# Create a debug signing key to sign our application.
|
||||
if [ ! -f .keystore ]; then
|
||||
"$ANDROID_JBR/bin/keytool" -genkey -dname "CN=Android Debug, O=Android, C=US" -keystore .keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 30000
|
||||
keytool -genkey -dname "CN=Android Debug, O=Android, C=US" -keystore .keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 30000
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
fi
|
||||
|
||||
# Build the shared lib
|
||||
odin build jni -target:linux_arm64 -subtarget:android -build-mode:shared
|
||||
if [[ $1 == "release" ]]; then
|
||||
odin build . -target:linux_arm64 -subtarget:android -build-mode:shared -o:speed -define:RELEASE_BUILD=true
|
||||
else
|
||||
odin build . -target:linux_arm64 -subtarget:android -build-mode:shared -debug -show-system-calls
|
||||
fi
|
||||
|
||||
name=$(basename "$PWD")
|
||||
|
||||
# Create the proper lib directories and move the shared lib to them
|
||||
# Rename the shared lib to match what we specified in the AndroidManifest.xml file
|
||||
# for the android.app.lib_name metadata value
|
||||
mkdir -p android/lib/lib/arm64-v8a
|
||||
mv jni.so android/lib/lib/arm64-v8a/libmain.so
|
||||
mv $name.so android/lib/lib/arm64-v8a/libmain.so || exit 1
|
||||
|
||||
# Bundle the directory into an apk
|
||||
odin bundle android android -android-keystore:.keystore -android-keystore-password:"android"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
APK=native_example.apk
|
||||
ANDROID_SDK_ROOT=/home/illusion/Android/Sdk
|
||||
ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125
|
||||
ANDROID_TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
|
||||
ANDROID_JBR=/home/illusion/android-studio/jbr
|
||||
BUILD_TOOLS=34.0.0
|
||||
|
||||
get_package_activity() {
|
||||
PACKAGE=$("$ANDROID_SDK_ROOT/build-tools/$BUILD_TOOLS/aapt" dump badging "bin/$APK" | grep package | awk -F"'" '{print $2}')
|
||||
ACTIVITY=$("$ANDROID_SDK_ROOT/build-tools/$BUILD_TOOLS/aapt" dump badging "bin/$APK" | grep launchable-activity | awk -F"'" '{print $2}')
|
||||
}
|
||||
|
||||
launch() {
|
||||
get_package_activity
|
||||
"$ANDROID_SDK_ROOT/platform-tools/adb" shell am start -n "$PACKAGE/$ACTIVITY"
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
}
|
||||
|
||||
launch
|
||||
@@ -36,7 +36,7 @@ engine_init_display :: proc "contextless" (engine: ^engine) {
|
||||
|
||||
display := egl.GetDisplay(egl.DEFAULT_DISPLAY)
|
||||
if display == egl.NO_DISPLAY {
|
||||
LOG(.INFO, "NativeExampleOdin", "Naterror with eglGetDisplay")
|
||||
LOG(.INFO, "NativeExampleOdin", "error with eglGetDisplay")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user