Unable to locate an executable at "/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/jarsigner"

Viewed 712

I'm trying to build a release bundle on android and for some reason, it started to give me this error:

Command:

flutter build appbundle --target-platform android-arm,android-arm64 --build-number=$VERSION_CODE --build-name=$VERSION_NAME

Error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageReleaseBundle'.
> java.util.concurrent.ExecutionException: java.lang.RuntimeException: jarsignerfailed with exit code 2 :
  Unable to locate an executable at "/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/jarsigner" (-1)

* 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 1m 0s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done                        61.8s
Gradle task bundleRelease failed with exit code 1

I've checked, the jarsigner binary is not on that directory. Tried to see if is somewhere installed with: whereas jarsigner and is located in /usr/bin/jarsigner

I tried to copy/symlink the file in the directory Android Studio expects it to be but once I do that and execute the build command again the bundleRelease task of Gradle remains at Running Gradle task 'bundleRelease'... (This is taking an unexpectedly long time.) and doesn't finish.

I can build APK for Release without a problem.

Flutter Doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-AL)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.2)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart-specific functionality.
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

Java version outputs:

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)

I have always built an app like this, for more than a year.

Thanks in advance for the help.

1 Answers

If you are using android studio, change the JDK Location used by Gradle from embedded to OpenJDK (the one you have installed manually)

enter image description here

Do a clean build then. Or create a new project and copy-paste old code.

Related