Visual Studio for Mac 2019:更新后无法在 Android 上构建和部署

Visual Studio for Mac 2019 : unable to build and deploy on Android after update

我在 Mac 上工作,我刚刚将 Visual Studio for Mac 20109 更新到最新版本:Version 8.8(内部版本 2913)

在此之后,我无法再build/deploy Android 我开发的应用程序。

我创建了一个空的新 Xamarin.Forms 项目,但我遇到了同样的问题。

输出为:

zipalign
    /Users/pacodoso/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.0/zipalign exited with value: 0
    Creating: /var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk/Mono.Android.Platform.ApiLevel_28.apk
    Executing: /Users/pacodoso/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25/bin/java -jar "/Users/pacodoso/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.0/lib/apksigner.jar" sign --ks "/Users/pacodoso/.local/share/Xamarin/Mono for Android/debug.keystore" --ks-key-alias "androiddebugkey" --out "/var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk/Mono.Android.Platform.ApiLevel_28.apk" --ks-pass "pass:android" --key-pass "pass:android" "/var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk/unsigned.apk"
    /Users/pacodoso/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.0/zipalign exited with value: 0
    Creating: /var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk/Mono.Android.Platform.ApiLevel_28.apk
    Executing: /Users/pacodoso/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25/bin/java -jar "/Users/pacodoso/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.0/lib/apksigner.jar" sign --ks "/Users/pacodoso/.local/share/Xamarin/Mono for Android/debug.keystore" --ks-key-alias "androiddebugkey" --out "/var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk/Mono.Android.Platform.ApiLevel_28.apk" --ks-pass "pass:android" --key-pass "pass:android" "/var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk/unsigned.apk"
    Removing temporary directory: /var/folders/yv/7m_37_p15g1bymlxqxmcgv3r0000gn/T/2medl58y.mxk
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  Deployment failed
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Xamarin.AndroidTools.AndroidSdkToolException: Error: A JNI error has occurred, please check your installation and try again
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.defineClass1(Native Method)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.access0(URLClassLoader.java:74)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.run(URLClassLoader.java:369)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.run(URLClassLoader.java:363)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.security.AccessController.doPrivileged(Native Method)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.PlatformPackage.GetPlatformPackagePathAsync (System.Int32 apiLevel, System.String aaptPath, Xamarin.AndroidTools.IProgressNotifier progressReporter, System.Threading.CancellationToken token) [0x00270] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/PlatformPackage.cs:139 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.InstallSharedPlatformAsync () [0x000a9] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:349 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.EnsureCorrectSharedRuntimes () [0x0017a] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:270 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x001f9] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:198 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:123 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Xamarin.AndroidTools.AndroidSdkToolException: Error: A JNI error has occurred, please check your installation and try again
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.defineClass1(Native Method)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.access0(URLClassLoader.java:74)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.run(URLClassLoader.java:369)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.run(URLClassLoader.java:363)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.security.AccessController.doPrivileged(Native Method)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.PlatformPackage.GetPlatformPackagePathAsync (System.Int32 apiLevel, System.String aaptPath, Xamarin.AndroidTools.IProgressNotifier progressReporter, System.Threading.CancellationToken token) [0x00270] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/PlatformPackage.cs:139 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.InstallSharedPlatformAsync () [0x000a9] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:349 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.EnsureCorrectSharedRuntimes () [0x0017a] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:270 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x001f9] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:198 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/451/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:123 
Done building target "_Upload" in project "DebugAndroidIssue.Android.csproj" -- FAILED.

Done building project "DebugAndroidIssue.Android.csproj" -- FAILED.

Build FAILED.

你有这条线:

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

也许您应该检查系统和项目中的 Java 版本。尝试更新它并重试,因为它们可能不是相同的版本号。