Cannot find jarsigner in JAVA_HOME or PATH
-
Tried to build my app for Android with API level 30 (Android 11) and QT Creator 4.15.1, but got "Cannot find jarsigner in JAVA_HOME or PATH."
JAVA_HOME is set as follows:
JAVA_HOME=C:/Program Files/Android/Android Studio/jre
but there is no jarsigner in "C:\Program Files\Android\Android Studio\jre\bin"
I got this path from Android Studio settings:
should I install some other JDK version?
see my blog post for details.
-
from your blog I can see that your Manifest is wrong.
This should be removed: <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
and to be added to .pro:
ANDROID_MIN_SDK_VERSION = "21"
ANDROID_TARGET_SDK_VERSION = "30"probably because your manifest is wrong, you haven't updated your Templates ? This is really important for Qt 5.15 and QtC 5.14.1
don't know if this is the case for your error, but yould try it -
@ekkescorner said in Cannot find jarsigner in JAVA_HOME or PATH:
from your blog I can see that your Manifest is wrong.
This should be removed: <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
and to be added to .pro:
ANDROID_MIN_SDK_VERSION = "21"
ANDROID_TARGET_SDK_VERSION = "30"probably because your manifest is wrong, you haven't updated your Templates ? This is really important for Qt 5.15 and QtC 5.14.1
don't know if this is the case for your error, but yould try itAdd as you write and remake Android Manifests (i have 2: for 32 and 64bit version) and there was no functional difference in them compared to the old ones. But there was few at gradle file. Still, same outcome: can build regular aab, signed apks, but not signed aab.
-
@Alex-Rus said in Cannot find jarsigner in JAVA_HOME or PATH:
can build regular aab, signed apks, but not signed aab.
don't know if this helps:
I also can build and sign APKs (Qt 5.15 / QtC 4.15.1)
aab from QtC build is always unsigned
to get aab signed I added a Custom process Step
command:jarsigner
arguments:-verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore "path_to_mykeystore" "path_to_myApp.aab" "myKeystoreAlias" -storepass "myKeystorePassword" -keypass "myKeyPassword"
figured this out with some help from @Jerome-GodboutBTW: why do you have 2 different Manifests because of 32 bit and 64 bit ?
-
@ekkescorner said in Cannot find jarsigner in JAVA_HOME or PATH:
aab from QtC build is always unsigned
It's strange, before updating to 5.15 version I could easily sign and upload bundles to the Play Market
to get aab signed I added a Custom process Step
command:jarsigner
arguments:-verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore "path_to_mykeystore" "path_to_myApp.aab" "myKeystoreAlias" -storepass "myKeystorePassword" -keypass "myKeyPassword"
figured this out with some help from @Jerome-GodboutThx for info, but the "Invalid command" is writing to me and "Could not start process "jarsigner"" in Compile Output
![alt text]BTW: why do you have 2 different Manifests because of 32 bit and 64 bit ?
As far as I remember (I did this a year ago), this is to assign a unique ID to different versions (the Play Market requires it)
-
@Alex-Rus don't know why you cannot start jarsigner - I'm working on macOS Catalina with JDK 8, no Android Studio installed and QtCreator 4.15.1 by magic installed all what's needed. no problems with Android or iOS
you don't need 2 Android Manifests to upload 32-bit and 64-bit APKs to PlayStore, but you must make sure that VersionCode is different.
here's how you can do this with 1 Manifest - let QtC fill in the VersionName and VersionCode:android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --"
inside your .pro you can calculate the VersionCode:
# deploying 32-bit and 64-bit APKs you need different VersionCode # here's my way to solve this - per ex. Version 1.2.3 # aabcddeef aa: 21 (MY_MIN_API), b: 0 (32 Bit) or 1 (64 Bit) c: 0 (unused) # dd: 01 (Major Release), ee: 02 (Minor Release), f: 3 (Patch Release) # VersionName 1.2.3 # VersionCode 32 Bit: 210001023 # VersionCode 64 Bit: 211001023 defineReplace(droidVersionCode) { segments = $$split(1, ".") for (segment, segments): vCode = "$$first(vCode)$$format_number($$segment, width=2 zeropad)" equals(ANDROID_ABIS, arm64-v8a): \ prefix = 1 else: equals(ANDROID_ABIS, armeabi-v7a): \ prefix = 0 else: prefix = 2 # add more cases as needed return($$first(prefix)0$$first(vCode)) } MY_VERSION = 1.2 MY_PATCH_VERSION = 3 MY_MIN_API = 21 ANDROID_VERSION_NAME = $$MY_VERSION"."$$MY_PATCH_VERSION ANDROID_VERSION_CODE = $$MY_MIN_API$$droidVersionCode($$MY_VERSION)$$MY_PATCH_VERSION
there are different ways to number VersionCode for different archs, take a look at:
https://www.qt.io/blog/2019/06/28/comply-upcoming-requirements-google-play
hint: you must useANDROID_ABIS
instead ofANDROID_TARGET_ARCH
https://androidbycode.wordpress.com/2015/06/30/android-ndk-version-code-scheme-for-publishing-apks-per-architecture/
https://medium.com/dipien/versioning-android-apps-d6ec171cfd82also you have to remove MinSDK and TargetSDK from Manifest, because it's now part of gradle.properties, where QtC will put it in from this in .pro:
ANDROID_MIN_SDK_VERSION = "21" ANDROID_TARGET_SDK_VERSION = "29"
will blog about all of this soon - just "moving" more then 30 projects from 5.13.2 to 5.15...