feat: initial mobile support
ref https://github.com/tauri-apps/tauri-action/issues/525 (not closing it)
Package Changes Through 2a2f2a82549f0aacb51f9f7720471f118386ae7e
No changes.
Add a change file through the GitHub UI by following this link.
Read about change files or the docs at github.com/jbolda/covector
Any updates on this pull request? Tauri is v2 stable now :D
i didn't look into this since my last commit. The main blocker here is stupid iOS again (mostly me not knowing how to set it up so we can test it), but also the user facing config, not too happy with the current includeAndroid/includeIOS approach, that was mostly for easy testing (but can't really think of anything better either...)
includeAndroid / includeIOS isn’t entirely unheard of. In a lot of binaries, they use flags that are nothing more than withModule or usesModule
Ah...I have to say I can't agree with you more, iOS does cause a lot of trouble (even when built on local machines). Have you ever considered splitting iOS and Android? We can start with a partial solution for Android only, which already solves some of the problems.
nah i'll add ios too but let users test it instead of testing it in this repo. Apple gatekeeps .ipa generation behind a (paid?) developer account even though it's literally just a zip file so we can't test it ourselves here yet.
just need to update the search paths, some initial docs and we're good to go. idk if that will happen today but at least this week.
btw, in case someone didn't know, you can use PRs in your own workflow. in this case by replacing tauri-apps/tauri-action@v0 with tauri-apps/tauri-action@mobile (will break once the branch is deleted so using commit hashes instead of the branch name would prob be a good idea)
nah i'll add ios too but let users test it instead of testing it in this repo. Apple gatekeeps .ipa generation behind a (paid?) developer account even though it's literally just a zip file so we can't test it ourselves here yet.
You only need a paid account for entitlements, which usually implies some sort of distribution. You can generate an IPA and test it locally with Xcode for free, so you'd be fine leaving it to the user. Doing it without Xcode is hacky and convoluted, though.
But, the actual reason I was here is...
Android explicitly disabled clear text traffic and enabling it requires access to the manifest. I have yet to find any sort of command or anything that would change it without manually editing the manifest. That more or less makes a completely automated build out of the question. Are there any plans to support something to handle that (down the road)?
yes, something like this (iirc "patch" files) is planned but mostly unrelated to this repo. This is why the templates don't have the gen/android & gen/apple folders in the .gitignore files at the moment.
Thanks for the info. I had a feeling it may be somewhat unrelated, but also means anyone who needs such edits won't be able to use it. Not your fault, though.
Any updates on the android support? it has been 2 months since last commit
Android should work. check out the git diff of this pr for an example workflow (it's missing signing which is required to be able to install the APK!)
Android should work. check out the git diff of this pr for an example workflow (it's missing signing which is required to be able to install the APK!)
will the signing be included? looking for that to be also in the workflow
the test workflow probably won't but i'll add something to the docs/example then. For now it's explained here https://v2.tauri.app/distribute/sign/android/
splits {
abi {
isEnable = true
reset()
include("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
isUniversalApk = true
}
}
do I add this to my build.gradlew.kts or handle both the universal and the split at the workflow level? or is this supported?
- platform: 'ubuntu-22.04'
args: '--apk'
mobile: true
- uses: tauri-apps/tauri-action@3c20edcd47f6c6fa6d7bd17d279e1c1b454ff57d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
includeAndroid: ${{ matrix.mobile || false }}
args: ${{ matrix.args }}
Run tauri-apps/tauri-action@3c20edcd47f6c6fa6d7bd17d279e1c1b454ff57d
with:
tagName: v__VERSION__
releaseName: v__VERSION__
releaseBody: See the assets to download this version and install.
releaseDraft: true
prerelease: false
includeAndroid: true
args: --apk
projectPath: .
includeDebug: false
includeRelease: true
includeIOS: false
includeUpdaterJson: true
updaterJsonKeepUniversal: false
env:
CARGO_HOME: /home/runner/.cargo
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
CACHE_ON_FAILURE: false
JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.13-11/x64
JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.13-11/x64
ANDROID_HOME: /usr/local/lib/android/sdk
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
GITHUB_TOKEN: ***
running bun [ 'tauri', 'build', '--apk' ]
$ tauri build --apk
error: unexpected argument '--apk' found
tip: to pass '--apk' as a value, use '-- --apk'
Usage: bun run tauri build [OPTIONS] [ARGS]...
For more information, try '--help'.
is this just me or there is something wrong with my setup?
args: --apk should be -- --apk according to the error
args: --apkshould be-- --apkaccording to the error
error: unexpected argument '--apk' found
Usage: cargo build [OPTIONS]
For more information, try '--help'.
failed to build app: failed to build app
Error failed to build app: failed to build app
error: script "tauri" exited with code 1
Error: Command failed with exit code 1: bun tauri build -- --apk
wasted my time, the issue lies on for some reason the includeAndroid is ignored
@YuenSzeHong To be honest, Idk what would you like to do. Tauri use bun tauri android build to create a android apk bundle instead of using --apk, do you mean android build?
@YuenSzeHong To be honest, Idk what would you like to do. Tauri use
bun tauri android buildto create a android apk bundle instead of using--apk, do you meanandroid build?
@fu050409 well, thats what exactly i want to do, i want to do desktop and android build in same matrix and it don't work
and doesn't tauri android build defaults to aab instead of apk?
name: 'release'
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
mobile: true
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: setup bun
uses: oven-sh/setup-bun@v1
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: |
${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
${{ matrix.platform == 'ubuntu-22.04' && 'aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android' || '' }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- name: Setup Java (Android only)
if: matrix.mobile
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Android SDK (Android only)
if: matrix.mobile
uses: android-actions/setup-android@v3
- name: Install NDK (Android only)
if: matrix.mobile
run: sdkmanager "ndk;27.0.11902837"
- name: setup Android signing (Android only)
if: matrix.mobile
run: |
cd src-tauri/gen/android
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
- name: install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: bun install # change this to npm or pnpm depending on which one you use.
- uses: tauri-apps/tauri-action@3c20edcd47f6c6fa6d7bd17d279e1c1b454ff57d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.0.11902837
with:
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
includeAndroid: ${{ matrix.mobile || false }}
args: ${{ matrix.args }}
Update: finally worked, how do I choose to build apk or aab for android? also can I have the splits along with the universal?
I don't really want aab in my release, and I want to include splits in my release, while the current state don't support this.
You will need 2 Ubuntu entries in the matrix. One for desktop and one for mobile with the extra cli args.
wasted my time, the issue lies on for some reason the includeAndroid is ignored
error: unexpected argument '--apk' found
tip: to pass '--apk' as a value, use '-- --apk'
My apologies, I guess? I diagnosed the error, not the entire build.
You will need 2 Ubuntu entries in the matrix. One for desktop and one for mobile with the extra cli args.
It should be noted somewhere that iOS will only build if runs-on: macos is set.
@YuenSzeHong Also note that the arguments for the splits in tauri are different than the ones used in android studio. They use the same labels as the rust targets
arm64-v8a => aarch64
armeabi-v7a => armv7
x86 => i686
x86_64 => x86_64
It should be noted somewhere that iOS will only build if runs-on: macos is set.
This will of course be added to the readme too once I actually update the readme.
Edit: stupid GitHub app didn't want to give me a link to that line so you get a screenshot instead 🤣
It may be easier to flat out say it only runs on macOS runners. I can see someone reading that and being like “well how do I fix that?”
(To be fair, Mac shoots themselves in the foot with the restrictions)
Hmm yeah, the wording is not final and I will keep that in mind, thanks. Just wanted to make it clear that setting it on the wrong runner won't make the workflow fail (though maybe it should).
error: unrecognized subcommand 'ios' is the error Tauri throws on Linux and that’s easily mistaken for Tauri being broken.
Yeah, but that is not really relevant for us here. Again, at least with the current plan, the action will ignore the includeIOS setting on Linux/windows and therefore just skip the whole build.
The current implementation may not do that yet, it's a draft after all.
Apologies if my intention was unclear. I am aware it is a draft, but must have missed where it ignores the command on other platforms. Since I don't know your actual plans until they are published, I will hold any comments until it's no longer a draft.
Best of luck.
Yeah it's probably not in the code yet, but that's what I wanted to say in the screenshot :)
Anyway, thanks for the feedback so far!
You will need 2 Ubuntu entries in the matrix. One for desktop and one for mobile with the extra cli args.
i have tried that, but the flow just failed instead of running the android flow with arguments, i assume the arguments for action should be the same as tauri android build?
do i need to pass --split-per-abi to get the splits? as i previously passed in --apk it failed