Repository navigation
Android
Home › Android
Experimental. Android support is new and still settling. It builds and runs real apps, but the
-appoptions, the[target.x.app]table intiko.tomland how tkControls behaves under a finger may still change, and it has been tried on few devices. Report what you find on the issue tracker.
tiko builds programs and apps for Android phones, tablets and the Android emulator. You write tiko; tiko compiles it, links it with Android's C library and packs it into a signed APK. There is no Java, Kotlin or Gradle project to keep.
| Android Setup Tutorial | Set up a Windows PC with Android Studio, then build, install and run a one-button app on the emulator or a phone |
| Android App Tutorial: Fasting | How a complete app was built: six screens in tkControls, SQLite on the phone, HTTPS sync with a server, light and dark themes, a signed release, with screenshots of each step |
| Compiler Option: -app | Every -app option, and the [target.x.app] table |
| Compiler Option: -target |
android-x86_64 and android-arm64
|
__TIKO_COMPILER__ and the target names |
TIKO_OS_ANDROID, for code that only Android should compile |
-
Two targets:
android-arm64for phones and tablets, andandroid-x86_64for the emulator on a PC. - Android 10 (API level 29) or newer on the device.
- Built on Windows. The Windows toolchain carries both Android targets. The Linux and macOS toolchains do not build for Android.
-
A console program with
-target android-arm64: a plain executable you run overadb shell.print, files, threads and the standard library behave as on Linux. -
An app with
-app: an SDL3 program packed as a signed APK, or as an App Bundle (.aab) for Google Play with-appbundle. tkControls is built on SDL3, so a tkControls program is the same source on the desktop and on the phone.
On Android every window is the whole screen, and tkControls adds what a phone needs:
- Touch: a tap is a click, a swipe scrolls with fling, a long press is a right click.
- Screens instead of windows: popups, dialogs and second forms are drawn inside the one window, and the BACK button closes the top one.
- The safe area: controls keep clear of the status bar, the navigation bar and a display cutout.
- The screen keyboard comes up for a focused text box, with the right kind of keys for it (a number pad for a numeric field, for example).
-
Sizes in dp:
tkHost_Scaleturns design units into pixels at the screen's density, so a 56-unit button suits a finger on any phone. - tkStack lays controls out one after another, the usual layout of a phone screen.
| Tool | For | Found through |
|---|---|---|
| the Android NDK, r30 or newer | every Android build: Android's C library and linker files |
ANDROID_NDK_HOME, else the newest ndk\<version> in the SDK |
| the Android SDK: Build-Tools and platform 36 | an app (-app) |
ANDROID_HOME, else %LOCALAPPDATA%\Android\Sdk
|
| a JDK, 17 or newer | an app: packing and signing are Java tools |
JAVA_HOME, else Android Studio's own (C:\Program Files\Android\Android Studio\jbr) |
| bundletool | an App Bundle (-appbundle) |
TIKO_ANDROID_BUNDLETOOL, else bundletool*.jar in bundletool\ beside the SDK |
| clang 18 or newer | every build, as on the desktop | as on the desktop (Quick Start) |
Android Studio installs the SDK and a JDK where tiko looks for them, and its SDK Manager adds the NDK, so a PC set up as the Android Setup Tutorial describes needs no environment variables.
#ifdef TIKO_OS_ANDROID
print "on a phone" '' goes to the device log: adb logcat -s tiko
#else
print "on the desktop"
#endifTIKO_OS_ANDROID is 1 on both Android targets. TIKO_OS_LINUX is not defined there:
Android's C library is not glibc, and code written for Linux would assume it is. In an app:
-
printgoes to the device log, whichadb logcat -s tikoshows. - The working directory is the app's private storage: files a program writes there stay until the app is removed.
-
openfor reading (and the read functions ofstd/fs) of a relative name that is not a file there reads the app's asset of that name, from the folder given with-appassets. -
exepathis".". - The program ends when its main code returns or reaches
end; Android then closes the app.
-
No HTTPS from the standard library.
std/tlsandstd/httphave no TLS library on Android. An app reaches a web server through Android's ownjava.net.HttpURLConnectionover JNI, as the Fasting app does. -
A thread that calls Java needs a real stack. Give
threadcreatea stack size (1 MB is plenty): with the default, the first JNI call on that thread stops the app. - No Java or Kotlin host. tiko makes the whole app; it cannot yet be a library inside an app written in Java or Kotlin.
- Few devices tried: the Android Studio emulator (API 29 and API 36, x86_64 and arm64) and one physical phone.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Android (experimental)
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Match
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Array Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- tiko test
- tiko doc
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing