Proguard failing Xamarin Android build - Unsupported class version number

xamarin
#1

Bitrise Build Issue Report template

Description of the issue

Xamarin build for iOS and Android is failing. Seems like the build is related to a the latest pro guard not being installed on your build servers

Environment:

Bitrise. Xamarin Archive step

Fails with the issue:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Tool exited with code: 10. Output: Error: Can’t read [/Library/Frameworks/Xamarin.Android.framework/Versions/7.0.2-42/lib/xbuild-frameworks/MonoAndroid/v7.0/mono.android.jar] (Can’t process class [android/app/ActivityTracker.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))

Reproducibility

  • Rebuild simulates issue.
0 Likes

#2

@godreikrisztian can you please have a look?

0 Likes

#3

Hi @ruaan,

thanks for the report!

I assume you are using the xamarin stable channel on bitrise.

This is a known issue in Xamarin.Android 7.0:

(One unfortunate complication with JDK 1.8 is that is not compatible with the outdated version of Proguard that is included in the Android SDK. Currently this will cause an error “Unsupported class version number [52.0]” when attempting to use the Proguard or Multidex features in Xamarin.Android. See 44187.)

As mentioned in this STO question, the workaround is to install manually the latest proguard version.

Please add a Script step before you Xamarin Archive step with followinf content input value:

#!/bin/bash
set -ex

PROGUARD_DOWNLOAD_URL="https://downloads.sourceforge.net/project/proguard/proguard/5.3/proguard5.3.2.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fproguard%2Ffiles%2F&ts=1486473732&use_mirror=netix"

temp_dir=$(mktemp -d)
PROGUARD_DOWNLOAD_PATH="$temp_dir/proguard5.3.2.tar"

PROGUARD_INSTALL_PATH="$ANDROID_HOME/tools/proguard"

# save progurad files
cp $PROGUARD_INSTALL_PATH/proguard-android.txt $temp_dir/proguard-android.txt
cp $PROGUARD_INSTALL_PATH/proguard-android-optimize.txt $temp_dir/proguard-android-optimize.txt
cp $PROGUARD_INSTALL_PATH/proguard-project.txt $temp_dir/proguard-project.txt

# replace proguard
wget -O "$PROGUARD_DOWNLOAD_PATH" "$PROGUARD_DOWNLOAD_URL"
tar -xf "$PROGUARD_DOWNLOAD_PATH" -C "$temp_dir"

rm -rf "$PROGUARD_INSTALL_PATH"
cp -R "$temp_dir/proguard5.3.2" "$PROGUARD_INSTALL_PATH"

tree "$PROGUARD_INSTALL_PATH" -L 1

# copy proguard files
cp $temp_dir/proguard-android.txt $PROGUARD_INSTALL_PATH/proguard-android.txt
cp $temp_dir/proguard-android-optimize.txt $PROGUARD_INSTALL_PATH/proguard-android-optimize.txt
cp $temp_dir/proguard-project.txt $PROGUARD_INSTALL_PATH/proguard-project.txt

tree "$PROGUARD_INSTALL_PATH" -L 1
1 Like

#4

What about these?

0 Likes

#5

Thanks. Resolved now using the Proguard install step.

1 Like

#6

Awesome, thanks for reporting @ruaan!

Just to be sure, this one was the solution, right? Proguard failing Xamarin Android build - Unsupported class version number

0 Likes

#7

Yeah, that’s the one.

1 Like

#8

Awesome, thank you, and Happy Building! :slight_smile:

0 Likes

#9

@viktorbenei
Hi!
Sorry to dig this discussion up but we have the same issue with native android build recently.
After updating target API and compile SDK version from 29 to 30, release build fails with “(Unsupported class version number [53.0] (maximum 52.0, Java 1.8)))”

I’ve tried use the proguard install step to install proguard7.0.1 but didn’t work.
Build from local works fine once after I replaced old version of proguard with 7.0.1.

Could you please take a look into it?

Thank you!

0 Likes

#10

Hi @shen.yingyin,

We’ve responded to you via email.

0 Likes