在Rider中为Xamarin.Android项目回退JDK版本至1.8
Hey there, I’ve run into this exact issue before with Xamarin.Droid and JDK versions—let’s get you sorted out step by step. The root problem here is that older Xamarin.Droid versions don’t play nice with JDK 9+, so forcing JDK 1.8 is the way to go. Here’s how to do it in Rider and system-wide:
1. First, confirm you have JDK 1.8 installed
If you don’t already have it, grab a compatible build (I recommend Azul’s Zulu JDK for licensing flexibility, or Oracle’s JDK 8 if you have a license). To check what you have installed, open Terminal and run:
java -version
If you see a 1.8.x version listed, note its installation path (usually something like /Library/Java/JavaVirtualMachines/jdk1.8.xxx.jdk/Contents/Home).
2. Set JDK 1.8 as the default in Rider’s global settings
- Open Rider and go to
Rider > Settings(or pressCmd + ,). - Navigate to
Build, Execution, Deployment > SDKs > JDK. - Click the
+button in the top-left corner, then selectJDKfrom the dropdown. - Browse to the JDK 1.8 installation path you noted earlier and select it.
- Click the star icon next to the new JDK entry to set it as your default global JDK.
3. Override JDK settings for your Xamarin.Droid project
Sometimes global settings don’t apply to individual projects, so let’s lock this in at the project level:
- Right-click your Xamarin.Droid project in the Solution Explorer and select
Properties. - Go to
Android Options > Advanced. - In the
Java Development Kit Locationdropdown, pick the JDK 1.8 you just added. - Double-check that
Java Compiler Versionis set to1.8(not higher) in the same section.
4. (Optional) Set JAVA_HOME system-wide (if Rider still isn’t picking it up)
If you’re still seeing issues, force your system to use JDK 1.8 by setting the JAVA_HOME environment variable:
- Open Terminal and edit your shell profile file. If you use Zsh, run
nano ~/.zshrc; for Bash, usenano ~/.bash_profile. - Add this line (replace the path with your actual JDK 1.8 location):
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.xxx.jdk/Contents/Home - Save the file (Ctrl+O, then Enter) and exit (Ctrl+X). Then run
source ~/.zshrc(orsource ~/.bash_profile) to apply the changes immediately. - Restart Rider to make sure it picks up the new environment variable.
5. Clean and rebuild your solution
Finally, clean out any cached build files that might be causing conflicts:
- Go to
Build > Clean Solutionin Rider’s top menu. - Once cleaning finishes, run
Build > Rebuild Solution. - Try launching your Android emulator again—this should resolve the
AdjustJavacVersionArgumentstask failure.
The key here is that Xamarin.Droid relies on specific JDK 8 APIs that were changed or removed in JDK 9+, so rolling back to 1.8 eliminates those compatibility gaps.
内容的提问来源于stack exchange,提问作者bejohi

