tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.73k stars 2.59k forks source link

[bug] Android: error: expected one of `*` or `{`, found `platform` #11524

Closed whittenator closed 1 month ago

whittenator commented 1 month ago

Describe the bug

Did a basic install like so:

npm create tauri-app@latest

Then did npm run tauri android init:

> tauri android init

Generating Android Studio project...
    Info "D:\\test\\drone-armor\\src-tauri" relative to "D:\\test\\drone-armor\\src-tauri\\gen/android\\drone_armor" is "..\\..\\..\\"
victory: Project generated successfully!
    Make cool apps! 🌻 🐕 🎉

Then attempted to run the dev environment npm run tauri android dev:

> drone-armor@0.1.0 tauri
> tauri android dev

    Info Detected connected device: Pixel_Tablet_API_35 (sdk_gphone64_x86_64) with target "x86_64-linux-android"
    Running BeforeDevCommand (`npm run dev`)

> drone-armor@0.1.0 dev
> vite

  VITE v5.4.10  ready in 343 ms

  ➜  Local:   http://localhost:1420/
   Compiling wry v0.46.3
   Compiling tauri v2.0.6
   Compiling tauri-plugin-shell v2.0.2
   Compiling drone-armor v0.1.0 (D:\test\drone-armor\src-tauri)
   Compiling tauri-runtime-wry v2.1.2
error: expected one of `*` or `{`, found `platform`
 --> src\lib.rs:7:20
  |
7 | #[cfg_attr(mobile, tauri::mobile_entry_point)]
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `*` or `{`
  |
  = note: this error originates in the macro `::tauri::tao::android_binding` which comes from the expansion of the attribute macro `tauri::mobile_entry_point` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `drone-armor` (lib) due to 1 previous error
`Failed to run `cargo build`: command ["cargo", "build", "--package", "drone-armor", "--manifest-path", "D:\\test\\drone-armor\\src-tauri\\Cargo.toml", "--target", "x86_64-linux-android", "--lib"] exited with code 101
    Error `Failed to run `cargo build`: command ["cargo", "build", "--package", "drone-armor", "--manifest-path", "D:\\test\\drone-armor\\src-tauri\\Cargo.toml", "--target", "x86_64-linux-android", "--lib"] exited with code 101

Reproduction

Please see the bug description for reproduction.

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 129.0.2792.89
    ✔ MSVC: 
        - Visual Studio Build Tools 2019
        - Visual Studio Community 2022
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.18.0
    - npm: 10.8.2

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.4
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response

amrbashir commented 1 month ago

Can you share your tauri.conf.json file?

whittenator commented 1 month ago

Yeah, my tauri.conf.json is attached. tauri.conf.json

{
  "$schema": "https://schema.tauri.app/config/2",
  "productName": "test-app",
  "version": "0.1.0",
  "identifier": "com.test.app",
  "build": {
    "beforeDevCommand": "npm run dev",
    "devUrl": "http://localhost:1420",
    "beforeBuildCommand": "npm run build",
    "frontendDist": "../dist"
  },
  "app": {
    "windows": [
      {
        "title": "test-app",
        "width": 800,
        "height": 600
      }
    ],
    "security": {
      "csp": null
    }
  },
  "bundle": {
    "active": true,
    "targets": "all",
    "icon": [
      "icons/32x32.png",
      "icons/128x128.png",
      "icons/128x128@2x.png",
      "icons/icon.icns",
      "icons/icon.ico"
    ]
  }
}
alanyang commented 1 month ago

me too,create new project don't change any code,compile for android,same error image

` Environment

[-] Packages

[-] Plugins

[-] App

tianshuapp commented 1 month ago

I've encountered the same problem, tauri info:

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 130.0.2849.52
    ✔ MSVC: Visual Studio Professional 2022
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.11.1
    - yarn: 1.22.19
    - npm: 10.2.4

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.4
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite
IT-ess commented 1 month ago

Same for me. tauri info :

[✔] Environment
    - OS: Arch Linux Rolling Release x86_64 (X64)
    ✔ webkit2gtk-4.1: 2.46.2
    ✔ rsvg2: 2.59.1
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (2024-05-07)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 23.1.0
    - pnpm: 9.12.3
    - npm: 10.9.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.4
    - tauri-cli 🦀: 2.0.4
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1
    - tauri-plugin-nfc 🦀: 2.0.1
    - @tauri-apps/plugin-nfc : 2.0.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
ecmel commented 1 month ago

"tao" update 0.30.3 to 0.30.4 causes the issue

MirazMac commented 1 month ago

Facing the same issue:

> livsports-next@0.1.0 tauri
> tauri info

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 129.0.2792.89
    ✔ MSVC: Visual Studio Build Tools 2019
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.14.0
    - pnpm: 9.12.3
    - yarn: 1.22.22
    - npm: 9.4.1
    - deno: deno 2.0.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.4
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-http 🦀: 2.0.3
    - @tauri-apps/plugin-http : 2.0.1
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : not installed!
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
whittenator commented 1 month ago

"tao" update 0.30.3 to 0.30.4 causes the issue

@alanyang @ecmel @MirazMac @amrbashir This is the quick fix, went into my Cargo.toml and specified tao = "=0.30.3" underneath my [dependencies]. As @ecmel stated it's the tao version 0.30.4 that's causing the problems.

amrbashir commented 1 month ago

Thank you, I have opened a PR to fix it in https://github.com/tauri-apps/tao/pull/1000

amrbashir commented 1 month ago

Fix is published run cargo update -p tao in src-tauri (and remove tao = "=0.30.3" if you added that workaround)