Unable to sign APK due to FileAlreadyExistsException
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
- Generated an AAB file using command
ionic cordova build android --release - New file created successfully, named
aab-release.aab - 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 - I'm prompted to enter the password for the keystore, enter the correct keystore password
- 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
Could you please attach a sample project to reproduce this?
Command line add : --mode=universal
I have the same problem as you. I solved the problem.
Command line add : --mode=universal
Hi @xq48799220 - I'll give that a go, what does that flag do?
The APKS file contains only one APK. I'm only using it for testing. And the test passed.
I'll give that a go - just don't understand why the original error @xq48799220
follow the error prompt. XXXXX /standalone-armeabi_mdpi.apk should be delete. but the deletion failed.
This should be fixed in the latest version.