question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to sign APK due to FileAlreadyExistsException

See original GitHub issue

Describe the bug Unable to generate APKS file from an AAB bundle, getting an Unable to sign APK error caused by a FileAlreadyExistsException within C:/Users/name/AppData/Local/Temp

Bundletool version(s) affected Version: 1.8.1

Stacktrace

[BT:1.8.1] Error: Unable to sign APK.
com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Unable to sign APK.
        at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
        at com.android.tools.build.bundletool.io.ApkSigner.signApk(ApkSigner.java:84)
        at com.android.tools.build.bundletool.io.ZipFlingerApkSerializerHelper.writeToZipFile(ZipFlingerApkSerializerHelper.java:173)
        at com.android.tools.build.bundletool.io.ZipFlingerApkSerializerHelper.writeToZipFile(ZipFlingerApkSerializerHelper.java:112)
        at com.android.tools.build.bundletool.io.StandaloneApkSerializer.writeToDiskInternal(StandaloneApkSerializer.java:76)
        at com.android.tools.build.bundletool.io.StandaloneApkSerializer.writeToDisk(StandaloneApkSerializer.java:43)
        at com.android.tools.build.bundletool.io.ApkSetBuilderFactory$ApkSetArchiveBuilder.addStandaloneApk(ApkSetBuilderFactory.java:130)
        at com.android.tools.build.bundletool.io.ApkSerializerManager$ApkSerializer.serialize(ApkSerializerManager.java:495)
        at com.android.tools.build.bundletool.io.ApkSerializerManager.lambda$null$4(ApkSerializerManager.java:233)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.nio.file.FileAlreadyExistsException: C:\Users\bengrah\AppData\Local\Temp\ApkSigner2236382018700181045\signed.apk -> C:\Users\bengrah\AppData\Local\Temp\AutoValue_BuildApksCommand3237083126039129873\standalones\standalone-armeabi_mdpi.apk
        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileCopy.move(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source)
        at java.nio.file.Files.move(Unknown Source)
        at com.android.tools.build.bundletool.io.ApkSigner.signApk(ApkSigner.java:75)
        ... 13 more

To Reproduce

  1. Generated an AAB file using command ionic cordova build android --release
  2. New file created successfully, named aab-release.aab
  3. Run the following command: java -jar .\bundletool.jar build-apks --bundle=app-release.aab --output=./app-signed.apks --ks=C:/keystore/location/my.keystore --ks-key-alias=alias_name
  4. I’m prompted to enter the password for the keystore, enter the correct keystore password
  5. Hit Return, nothing happens for about 20s

Expected behavior Generated an APKS file with some sort of successful message on the console.

Known workaround N/A

Environment: Windows 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
xq48799220commented, Mar 24, 2022

I have the same problem as you. I solved the problem.

Command line add : --mode=universal

0reactions
ymakhnocommented, Nov 4, 2022

This should be fixed in the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FileAlreadyExistsException - Android Developers
Returns the string explaining why the file system operation failed. ... be returned by getStackTrace() and printed by printStackTrace() and related methods.
Read more >
FileAlreadyExistsException when debug - MSDN - Microsoft
User365854 posted. When I try to debug I get the output below. I just keep pressing Debug until eventually it runs.
Read more >
How to fix issue Caused by: java.nio.file.NoSuchFileException ...
I was able to sign my apk fine until I did some android studio update or reset something in jar files. Not sure...
Read more >
Issues · google/bundletool - GitHub
Bundletool is a command-line tool to manipulate Android App Bundles ... 1.13.1 - build-apks on .aab generated by 1.8.2 incorrectly fails ...
Read more >
[UTIL][NOV 24, 2022] Apktool - Tool for reverse engineering ...
Senior Member · 1. Trying to decompile AOSP 5.1's Settings.apk using the 5.1 framework -- failed · 2. Trying to decompile the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found