- Where is the
examples
folder? vab
can't find my device when deploying?- The app force closes/crashes when I start it?
vab
can't find my SDK/NDK/JAVA_HOME?- I can't redirect (f)printf output to a file?
- How do I load assets embedded in the APK/AAB?
- I managed to compile some external .so libs, how do I include them?
vab
is able to build and run a lot of V's graphical examples out of the box.
V's graphical examples are typical those who import either gg
or sokol
.
Examples and apps using $if android {...}
code constructs is typically a
good indicator of Android support.
Many examples in V's source distribution examples/gg
and examples/sokol
works.
Some examples in the top level examples
directory also works, like examples/2048
.
Note that not all of V's examples have been written with Android in mind and may thus fail to compile or run properly, pull requests with Android fixes are welcome.
You need to enable debugging on your device.
vab
uses the adb
tool from the SDK - you can check by running adb devices
.
Make sure the device has an API level >= the API level used to build the app.
vab
will use the highest API level available in the SDK per default. You can change
what API is used with the --api <INT>
flag.
You can list all API's available with vab --list-apis
.
Additionally connect your device via USB to your computer and run vab
with the --log
flag.
This should capture the logs relevant to the app in question.
Currently vab
doesn't support shell expansion of special
characters like the tilde character (~
). So entries like these won't work:
ANDROID_SDK_HOME="~/Library/Android/Sdk"
JAVA_HOME="~/dev/java"
Instead please use full paths in env variables:
ANDROID_SDK_HOME="/Users/joe/Library/Android/Sdk"
JAVA_HOME="/home/joe/dev/java"
Per default vab
will enable println()
and eprintln()
output to go to your device's system log
for easy access via adb logcat
- this is done, for simplicity,
by redefining the C functions printf
and fprintf
.
To disable this behavior you can pass the --no-printf-hijack
to vab
.
Use os.read_apk_asset('relative/path/to/assets/file') or { panic(err) }
If you have a file logo.png
in assets/
- to load it, you need to call
os.read_apk_asset('logo.png') or { panic(err) }
Use the flag --libs <path libs with arch(s) folder>
(can be specified multiple times)
to include extra libraries.
The libraries need to reside inside a folder with the name of the architecture they
are compiled for e.g.: /tmp/libs/arm64-v8a
- this is normal and by convention for
other build systems used in Android development.
You can have one parent directory, containing libs for multiple archs:
/tmp/libs/arm64-v8a/libmain.so
/tmp/libs/armeabi-v7a/libmain.so
/tmp/libs/x86/libmain.so
... in which case passing --libs /tmp/libs
will include all of the libs found under /tmp/libs
.