简体   繁体   中英

Xamarin android App Deployment failing with error “apksigner.BAT” exited with code 2

Xamarin App Deployment failing with error "apksigner.BAT" exited with code 2 .

JDK version 1.8.162

Try downgrading the JDK to 1.8.131.

i faced the problems with 1.8.161 and 1.8.162.

If u are using JDK 9, then downgrade to JDK-8

Uninstalling JDK 9.x fixed it for me.

That Android Settings were pointing a JDK 8.x made no difference. JDK 9.x had to be removed to fix the issue.

I got the same error when building a Xamarin.Android app on Visual Studio.

It was caused by having migrated my keystore from JKS to PKCS12 format because

keytool.exe -list -v -keystore <path to my keystore>

kept giving me the following Warning: The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format Warning: The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format .

Bad idea to migrate, it appears apksigner.BAT requires the keystore be in the JKS format. I solved this issue by reverting back to my debug.keystore.old

In addition to JDK related answers above which is correct, also try to check PATH variable. There have to be latest installed JDK version. Solved my problem after days of checking different IDE's, machines and devices.

As others found, it's a conflict that occurs when you have a newer version of Java installed, such as JDK 9.

This shouldn't really be necessary but here is a workaround: Create a new batch file with the below content (update paths as necessary). You want to set JAVA_HOME so it points to the older version of Java.

Xamarin.bat:

@echo off
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_161
set PATH=%JAVA_HOME%\bin;%PATH%

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\"
start devenv.exe

I recently get an old poject from a client. It was giving same error in Visual Studio for Windows . In Visual Studio for Mac it was giving 1 error without displaying any Error Message .

The reason behind the error was that the client have specified a signing key which is not available on my system .

On Mac I just have to uncheck the apk signing option.

while on Windows I have to edit the csproj file to remove the signing key . Now the project builds successfully.

For me worked removing (or renaming) apksigner.bat from my current build tools directory (...AppData\\Local\\Android\\android-sdk\\build-tools\\28.0.0-rc1\\apksigner.bat)

After then, cleaned obj and Debug/Release directory->Rebuild->Deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM