tauri-apps / cargo-mobile2

Rust on mobile made easy!
Apache License 2.0
1.6k stars 76 forks source link

Failed to compile for Android: Unresolved references in Gradle script #392

Open matthunz opened 2 weeks ago

matthunz commented 2 weeks ago

Describe the bug I've been getting this error for a little while now, but I'm not sure if it has to do with my SDK/JDK version :thinking: removing the lines with errors seems to solve this however.

FAILURE: Build failed with an exception.

* Where:
Build file '/home/matt/Documents/dev2/gen/android/app/build.gradle.kts' line: 42

* What went wrong:
Script compilation errors:

  Line 42:     kotlinOptions {
               ^ Unresolved reference: kotlinOptions

  Line 43:         jvmTarget = "1.8"
                   ^ Unresolved reference: jvmTarget

Steps To Reproduce Create a new project with any template and run cargo android run.

Expected behavior I think we can just remove those lines, doing so has fixed compilation for me on both platforms.

Platform and Versions (please complete the following information): Host OS: MacOS Sequoia/Ubuntu 24.04.1 LTS Target OS: Android 13 Rustc: rustc 1.81.0 (eeb90cda1 2024-09-04)

Ouput of cargo mobile doctor:

[✔] cargo-mobile v0.17.2
    • Contains commits up to ""
    • Installed at "~/.cargo/.cargo-mobile2"
    • Ubuntu v24.04.1 LTS (Noble Numbat
    • rustc v1.81.0 (eeb90cda1 2024-9-4)

[✔] Android developer tools
    • SDK v26.1.1 installed at "~/Android/Sdk"
    • NDK v27.1.12297006 installed at "~/Android/Sdk/ndk/27.1.12297006"

[✔] Connected devices
    • Pixel 6