A demo application using Tauri for cross-platform native app deployment
Errors in build? You may be missing packages, check the prerequisites for your platform.
You may also need to install the javascript runtime 'bun' as it provides better
stability when building for android. See the Node MODULE_NOT_FOUND
Error
section for more information.
Finally, make sure that all javascript dependencies are installed.
pnpm i # or `npm i` or `yarn`
To build for the OS you are currently on;
pnpm tauri build # or `npm tauri build` or `yarn tauri build`
To build for android;
pnpm tauri android build # or `npm tauri android build` or `yarn tauri android build`
Building for platforms other than the one you are currently on will require some additional setup. See the tauri documentation for more information on building in a github action, or this github discussion for building in docker.
Note
The following steps can also be used to add tauri deployment to an existing
qooxdoo application. Add the "@tauri-apps/cli": ">=2.0.0-beta.0"
package to
your project's dev dependencies and follow the steps below.
pnpm tauri init --force # or `npm tauri init --force` or `yarn tauri init --force`
When prompted, enter the following responses:
- What is your app name?
- (your application name)
- What should the window title be?
- (title of your app window)
- Where are your web assets (HTML/CSS/JS) located, relative to the "/src-tauri/tauri.conf.json" file that will be created?
../compiled/build
- What is the url of your dev server?
http://localhost:5173
- What is your frontend dev command?
npm run dev
- What is your frontend build command?
npm run build
Open the src-tauri/tauri.conf.json
file and update the identifier
field to
match your application's reverse domain name.
- "identifier": "com.example"
+ "identifier": "com.yourdomain.yourapp"
Then to update the android configurations, run the following commands:
rm -rf src-tauri/gen/android
pnpm tauri android init # or `npm tauri android init` or `yarn tauri android init`
Note
This template has yet to be tested for iOS builds. Follow tauri's documentation for more information.
Note
If you delete and regenerate the gen/android
directory, you will need to
repeat everything in this section.
There is an archived version of tauri's documentation that provides a similar guide to the following steps.
To sign your android builds, you will need to create a keystore file. Run the following command to create a keystore file.
keytool -genkey -v -keystore $HOME/upload-keystore.jks -keyalg RSA -keysize 2048 -va
Tip
If an error occurs where keytool
is not found, it may be missing from your
PATH. Either add $JAVA_HOME/bin
to your PATH or use the full path to the
keytool
executable (eg, /opt/android-studio/jbr/bin/keytool
).
When prompted, enter the following responses:
- Enter keystore password:
- a secure password (remember this for later)
- Re-enter new password:
- the same password
- What is your first and last name?
- optional, may leave blank
- What is the name of your organizational unit?
- optional, may leave blank
- What is the name of your organization?
- optional, may leave blank
- What is the name of your City or Locality?
- optional, may leave blank
- What is the name of your State or Province?
- optional, may leave blank
- What is the two-letter country code for this unit?
UK
,DE
,FR
, etc.; whichever applies
- Is CN=Unknown, ... correct?
yes
Then create and populate the src-tauri/gen/android/keystore.properties
file.
touch src-tauri/gen/android/keystore.properties
echo "storePassword=your password here" >> src-tauri/gen/android/keystore.properties
echo "keyPassword=your password here" >> src-tauri/gen/android/keystore.properties
echo "keyAlias=upload" >> src-tauri/gen/android/keystore.properties
echo "storeFile=/home/<username>/upload-keystore.jks" >> src-tauri/gen/android/keystore.properties
Then in src-tauri/gen/android/app/build.gradle.kts
, add the signing configuration.
Tip
If you are having trouble getting the signing configuration to work, copy the contents of the file from this repo, as it has already been configured.
import java.util.Properties
+ import java.io.FileInputStream
...
+ val keyPropertiesFile = rootProject.file("key.properties")
+ val keyProperties = Properties()
+ keyProperties.load(FileInputStream(keyPropertiesFile))
android {
defaultConfig {
...
}
+ signingConfigs {
+ create("release") {
+ keyAlias = keyProperties["keyAlias"] as String
+ keyPassword = keyProperties["keyPassword"] as String
+ storeFile = file(keyProperties["storeFile"] as String)
+ storePassword = keyProperties["storePassword"] as String
+ }
+ }
buildTypes {
...
getByName("release") {
isMinifyEnabled = true
proguardFiles(
*fileTree(".") { include("**/*.pro") }
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
.toList().toTypedArray()
)
+ signingConfig = signingConfigs.getByName("release")
}
}
}
...
Note
If you delete and regenerate the gen/android
directory, you will need to
repeat everything in this section.
If node throws a MODULE_NOT_FOUND
error when running the tauri android build
command, the simplest solution is to instead use the bun
javascript runtime.
npm i -g bun
Then update
./src-tauri/gen/android/buildSrc/src/main/java/com/tauri/dev/kotlin/BuildTask.kt
to use the bun
runtime.
...
@TaskAction
fun assemble() {
- val executable = """node""";
+ val executable = """bun""";
try {
runTauriCli(executable)
} catch (e: Exception) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
runTauriCli("$executable.cmd")
} else {
throw e;
}
}
}
...