7

i built my first app in Xamarin (in Visual Studio 2019) and I want to deploy it to my android phone. (I actually dont really want to make the app public - just my phone would do the trick for now. I just dont want to root it.)

I followed these guides:

But once the archiving process is finished, and I was asked for the password of the 'Signing Identity' I defined before, I get the following error:

Signing packages failed. java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of Java Runtime(class file version 53.0), this version of the Java Runtime only recognizes class file versions of up to 52.0

I tried to install all sorts of Java versions (currently I am at 'Java 8 Update 241' and 'JDK 13.0.2') and made sure there is just one Java entry in my PATH variable pointing to the current version.

But it just wont change anything and I am out of Ideas, I hope somebody here can help me.

Thank you very much for your time in advance! Ben

Chetan Rawat
  • 578
  • 3
  • 17
Quackerjack
  • 83
  • 1
  • 4
  • 1
    I had this same issue in Jetbrains Rider when trying to debug a Xamarin.Android app on an emulator. @backspace83 answer fixed this for me. – Jordan B Apr 21 '20 at 14:03

2 Answers2

16

I faced the same problem. I solved it removing version 30.0.0 (rc2) of android build tools and keep only version 28.0.3. Probably it was a problem with build tools 30 and the latest version of Xamarin, who uses JDK 1.8. I also updated platform tools to version 29.0.6

backspace83
  • 342
  • 4
  • 10
  • 1
    I had this same issue in Jetbrains Rider when trying to debug a Xamarin.Android app on an emulator. This fixed it for me. Thanks! – Jordan B Apr 21 '20 at 14:03
  • 1
    @backspace83 you are a lifesaver - I also removed 30.0.0 (rc2) which had been installed by android studio also on my machine... I guess it picks the latest set of tools without regard to the jdk version being used - note to readers, you will need to delete the bin directory and recompile – tofutim May 15 '20 at 05:48
  • Notice that even in stable version, the 30.0 build tools is causing me this issue. Thanks for the tip ! – Miiite Jun 25 '20 at 10:14
2

Double-check that Java JDK 13.0.2 is selected in the Xamarin preferences:

Visual Studio: Tools > Options > Xamarin > Android Settings > Java Development Kit Location.

enter image description here

Here is a similar thread. You can refer to it.

https://stackoverflow.com/a/36585636/10627299

Leon
  • 8,404
  • 2
  • 9
  • 52
  • Thanks for the advice. When I try to point to JDK 13.0.2, I get an error that building with that version is not supported. https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/jdk9-errors – Quackerjack Feb 28 '20 at 15:01
  • As above link `To resolve these errors, you must install JDK 8 (1.8) as explained`, so you have to go back to the previous version – Leon Mar 01 '20 at 07:00