#How can I build Tauri v2 android plugin?

4 messages · Page 1 of 1 (latest)

runic bridge
#

I read these documents.

I can create plugin project and android project directories.

but android build is fail.

$ ./gradlew build
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment (build 17.0.11+9-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.11+9-Debian-1deb12u1, mixed mode, sharing)

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':extractDebugAnnotations'.
> Could not resolve all dependencies for configuration ':debugCompileClasspath'.
   > Could not resolve project :tauri-android.
     Required by:
         project :
      > No matching variant of project :tauri-android was found. The consumer was configured to find a component for use during compile-time, preferably optimized for Android, as well a
s attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.0.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains
.kotlin.platform.type' with value 'androidJvm' but:
          - No variants exist.

...(snip)

BUILD FAILED in 2s

gradle version is 8.9

Tauri

The cross-platform app building toolkit

Tauri

The cross-platform app building toolkit

past spade
#

Gradle expects the tauri api to be provided in your android folder in the .tauri/tauri-api subdirectory. I assume it is provided automatically once the plugin is integrated in an actual Tauri application.
For development purposes you could get the Tauri api from git:

# Go into the android folder of your plugin and create the tauri-api path
$ cd android
$ mkdir -p .tauri/tauri-api
# Clone the api from the tauri repo
$ git clone https://github.com/tauri-apps/tauri
# Copy the mobile api from the repo to the created path
$ cp -r tauri/core/tauri/mobile/android/. .tauri/tauri-api
# Remove the tauri repo
$ rm -rf tauri

That should allow Android Studio to successfully sync your gradle project.

runic bridge
#

@past spade Thank you for comment. I success build and edit!

boreal veldt
#

excelent!!!!