#Android build failed

48 messages · Page 1 of 1 (latest)

static lark
#

This occurs after running tauri android dev or build.
Does anyone know what the issue could be? I am developing on mac, currently testing out a project for android.

static lark
#

A previous error i had was because java was version 21, and gradle doesn't support the newest java versions. So i set my JVM to 17. export JAVA_HOME="/usr/libexec/java_home -v 17"
I now get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildSrc:compileKotlin'.
> Error while evaluating property 'compilerOptions.jvmTarget' of task ':buildSrc:compileKotlin'.
> Failed to calculate the value of property 'jvmTarget'.
> Unknown Kotlin JVM target: 21

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 531ms
       Error Failed to assemble APK: command ["/Users/pascaldachard/Desktop/proj/repo/rust/common/tauri-test/src-tauri/gen/android/gradlew", "--project-dir", "/Users/pascaldachard/Desktop/proj/repo/rust/common/tauri-test/src-tauri/gen/android"] exited with code 1

The old error is fixed. So java itself seems to understand the context. Seemingly kotlin is still trying to use the old JVM. How do i fix this?

#

It is not the same as my Android Studio

static lark
#
android {
    compileSdk = 33
    namespace = "com.tauri.app"
    defaultConfig {
        manifestPlaceholders["usesCleartextTraffic"] = "false"
        applicationId = "com.tauri.app"
        minSdk = 24
        targetSdk = 33
        versionCode = 1
        versionName = "1.0"
    }
    buildTypes {
        getByName("debug") {
            manifestPlaceholders["usesCleartextTraffic"] = "true"
            isDebuggable = true
            isJniDebuggable = true
            isMinifyEnabled = false
            packaging {                jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
                jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
                jniLibs.keepDebugSymbols.add("*/x86/*.so")
                jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
            }
        }
        getByName("release") {
            isMinifyEnabled = true
            proguardFiles(
                *fileTree(".") { include("**/*.pro") }
                    .plus(getDefaultProguardFile("proguard-android-optimize.txt"))
                    .toList().toTypedArray()
            )
        }
    }
    kotlinOptions {
        jvmTarget = "1.7"
    }
}
``` in my build.gradle.kts it is also constantly defined as 1.7
static lark
#

Does anyone know where kotlin might get called by version 21? i tried searching it across my project, but to no avail.

tawny pilot
#

Is this export JAVA_HOME="/usr/libexec/java_home -v 17" what you literally set it as? Can you try setting it as the resolved path, delete the src-tauri gen path and run android init again?

static lark
#

I have tried that, but i couldn't get it to work

tawny pilot
#

no, i mean type /usr/libexec/java_home -v 17 into your terminal and use the path this command returns as the value of the environment variable

static lark
#

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home"

Did this, deleted and re-initialised it. Still the same Kotlin error.

I also have to set the following:

export ANDROID_HOME="/Users/pascaldachard/Library/Android/sdk"
export NDK_HOME="/Users/pascaldachard/Library/Android/sdk/ndk/26.2.11394342"

Maybe i messed this up?

tawny pilot
#

hmm, looks alright to me

#

i use the android studio jdk as our docs say somewhere (not a requirement) but other than that the same and it works for me

#

i mean, in general it works for me, i've not yet tested your repo

static lark
#

that's very strange, hmm i used the android studio sdk, i could try setting the jdk to the android studio one

tawny pilot
#

hmm, your repo doesn't work for me on windows either

static lark
#

What did i do to mess this up 😂
I'll try create-tauri-app, with the right settings this time

tawny pilot
#

yeah, i'd recommend that too

#

i fixed your project on my end by doing npm i --save-dev @tauri-apps/cli && rm -rf src-tauri/gen/ && npm run tauri android init

#

Well, on windows at least

#

and with working i mean it compiles, the app can't connect to the frontend though

static lark
#

Lets gooo!!!!

#

Thank you so much

#

I think it's just whatever was cached when i ran android dev the first time

tawny pilot
static lark
static lark
#

Everything seems to work perfectly now, just with one issue

#

pain

dense karma
# static lark

I'm literally in the same boat. I tried converting the aab build to apk using bundletool. I did get an apk and got to install the app

#

but it just crashes after that 😥

static lark
dense karma
#

At the same time, I'm happy to make a pull request if it means I can get moving faster

static lark
dense karma
#

I just tried to compile it on my Linux device, it seems the issue isn't exclusive to Windows.

Maybe the problem is related to Gradle? I can't be sure yet tho

tawny pilot
#

as far as i know this can only mean one out of two things

  1. apk has the wrong arch, that usually can't be the case since tauri by default includes all 4 arches in one apk
  2. The app was not signed (which is a hard requirement). There are multiple (wip) guides but nothing perfect yet:
    <#1070344009664442418 message>
    https://next--tauri.netlify.app/next/guides/distribution/sign-android/
    https://docs.flutter.dev/deployment/android#signing-the-app (for flutter so it needs changes, but it's what we linked to when we had nothing else)
dense karma
#

I'll give it a try for my app as soon as I can, thanks!

static lark
dense karma
#

I tried it and now it successfully installs in my phone, but every time I try to open it, it crashes. I tried generating the APK in debug mode using the signingConfig there, and it works there (it doesn't crash the app anymore)

For the build mode APK, I tried both:

  • Android Studio's Build > Generate Signed Bundle / APK...
  • tauri's npm run tauri android build command
    where both cases don't work.
tawny pilot
#

hmm, maybe non-debug requires actual certificates and not a debug self-sign thingy? 🤔 Not sure, i'll ask around.

daring bronze
#

are you running on latest? i remember wry had a bug in the proguard rules

dense karma
#

Hey sorry I didn't know I was being asked this. I updated my app and now it gives an error:

error: failed to run custom build command for `uprofile_mobile v0.0.0 (D:\Projects\UProfile\uprofile_mobile\src-tauri)`

Caused by:
  process didn't exit successfully: `D:\Projects\UProfile\uprofile_mobile\src-tauri\target\release\build\uprofile_mobile-fdf90ce7680f2b5c\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=TAURI_CONFIG
  cargo:rerun-if-changed=tauri.conf.json
  cargo:rustc-cfg=mobile
  cargo:rustc-env=TAURI_ANDROID_PACKAGE_PREFIX=com_uprofile
  cargo:rerun-if-changed=D:\Projects\UProfile\uprofile_mobile\src-tauri\gen/android\tauri.settings.gradle
  cargo:rerun-if-changed=D:\Projects\UProfile\uprofile_mobile\src-tauri\gen/android\app\tauri.build.gradle.kts
  cargo:rerun-if-changed=permissions
  cargo:PERMISSION_FILES_PATH=D:\Projects\UProfile\uprofile_mobile\src-tauri\target\aarch64-linux-android\release\build\uprofile_mobile-be010a5290b6805f\out\app-manifest\__app__-permission-files
  cargo:rerun-if-changed=capabilities
Permission window:allow-internal-on-mousemove not found, expected one of app:default, .... (a lot more)

warning: build failed, waiting for other jobs to finish...
    Error `Failed to run `cargo build`: command ["cargo", "build", "--package", "uprofile_mobile", "--manifest-path", "D:\\Projects\\UProfile\\uprofile_mobile\\src-tauri\\Cargo.toml", "--target", "aarch64-linux-android", "--features", "tauri/custom-protocol tauri/rustls-tls", "--lib", "--release"] exited with code 101
#

Whereas my capabilities.json file already has window:allow-internal-on-mousemove and app:default on it

tawny pilot
#

remove window:allow-internal-on-mousemove again, iirc we removed that

dense karma
#

Okay, I removed "window:allow-internal-on-mousemove" and "window:allow-internal-on-mousedown", I'll run the build command again and let you know

dense karma
#

I've had a check and it compiles now. Thank you for your help!