#Android build failed
48 messages · Page 1 of 1 (latest)
Contribute to eatenpancreas/tauri-test development by creating an account on GitHub.
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
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
Does anyone know where kotlin might get called by version 21? i tried searching it across my project, but to no avail.
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?
Thank you for the reply! I'm not exactly sure what you mean with "resolved path",
export only sets the variable temporarily, do you mean i should set it permanently in something like .zshrc or .bash_profile?
I have tried that, but i couldn't get it to work
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
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?
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
that's very strange, hmm i used the android studio sdk, i could try setting the jdk to the android studio one
hmm, your repo doesn't work for me on windows either
What did i do to mess this up 😂
I'll try create-tauri-app, with the right settings this time
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
still getting Unknown Kotlin JVM target: 21 on my end with that
Lets gooo!!!!
Thank you so much
I think it's just whatever was cached when i ran android dev the first time
funny story, this ^ worked for me on macos too so i really have no clue what went wrong
i'm not sure, but i think when running android dev with the wrong jvm version, the kotlin version gets cached somewhere?
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 😥
At least i'm not the only one 😭 I think that's just the nature of being in beta, but it sucks
At the same time, I'm happy to make a pull request if it means I can get moving faster
Agreed, though i'm not very well versed on how kotlin works for android
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
as far as i know this can only mean one out of two things
- apk has the wrong arch, that usually can't be the case since tauri by default includes all 4 arches in one apk
- 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)
I'll give it a try for my app as soon as I can, thanks!
Just saw this, thank you alot! I will try this asap as well
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 buildcommand
where both cases don't work.
hmm, maybe non-debug requires actual certificates and not a debug self-sign thingy? 🤔 Not sure, i'll ask around.
are you running on latest? i remember wry had a bug in the proguard rules
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
remove window:allow-internal-on-mousemove again, iirc we removed that
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
I've had a check and it compiles now. Thank you for your help!
