mirror of
https://github.com/IllusionMan1212/android-native-example-odin.git
synced 2026-10-24 10:12:33 +00:00
Compare commits
4
Commits
a7dca34510
...
147b0ec325
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
147b0ec325
|
||
|
|
b643b0b3c2
|
||
|
|
ff674affbd
|
||
|
|
135171813f
|
@@ -4,10 +4,12 @@ This requires that you write some basic bindings to the Android NDK (or use mine
|
|||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
First you must adjust `build.sh` and `launch.sh` to have correct paths to Android SDK, Android NDK and the Jetbrains RT.
|
### Prerequisites
|
||||||
Then set `APK` variable to the desired apk package name. Use Android SDK to install build-tools and platform SDK.
|
- 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
|
# 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)
|
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)
|
||||||
|
|||||||
@@ -2,22 +2,20 @@
|
|||||||
|
|
||||||
## TODO: handle different ABIs, currently only builds for arm64
|
## 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.
|
# Create a debug signing key to sign our application.
|
||||||
if [ ! -f .keystore ]; then
|
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
|
if [ $? -ne 0 ]; then exit 1; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the shared lib
|
# Build the shared lib
|
||||||
odin build jni -target:linux_arm64 -subtarget:android -build-mode:shared
|
odin build . -target:linux_arm64 -subtarget:android -build-mode:shared
|
||||||
|
|
||||||
# Create the proper lib directories and move the shared lib to them
|
# 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
|
# Rename the shared lib to match what we specified in the AndroidManifest.xml file
|
||||||
# for the android.app.lib_name metadata value
|
# for the android.app.lib_name metadata value
|
||||||
mkdir -p android/lib/lib/arm64-v8a
|
mkdir -p android/lib/lib/arm64-v8a
|
||||||
mv jni.so android/lib/lib/arm64-v8a/libmain.so
|
mv android-native-example-odin.so android/lib/lib/arm64-v8a/libmain.so
|
||||||
|
|
||||||
# Bundle the directory into an apk
|
# Bundle the directory into an apk
|
||||||
odin bundle android android -android-keystore:.keystore -android-keystore-password:"android"
|
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)
|
display := egl.GetDisplay(egl.DEFAULT_DISPLAY)
|
||||||
if display == egl.NO_DISPLAY {
|
if display == egl.NO_DISPLAY {
|
||||||
LOG(.INFO, "NativeExampleOdin", "Naterror with eglGetDisplay")
|
LOG(.INFO, "NativeExampleOdin", "error with eglGetDisplay")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user