You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native run-android构建失败:UnsupportedClassVersionError问题求助

Fixing "Unsupported major.minor version 52.0" Error When Running react-native run-android on Mac

Hey there, let's break down this error you're hitting when trying to launch your React Native Android app. That UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0 message is a clear hint: your system's Java version is too old for the Android Gradle plugin your project uses. Version 52.0 maps directly to Java 8 (JDK 1.8)—so your terminal is running an older JDK that can't load the plugin's classes properly.

Here's how to fix it step by step:

Step 1: Confirm your current Java version

First, check what JDK your terminal is using. Run this command:

java -version

If the output shows a version like 1.7.x or older, that's definitely the root cause.

Step 2: Install JDK 8 (if you don't have it)

On Mac, the easiest way to get JDK 8 is via Homebrew. Run this command in your terminal:

brew install adoptopenjdk/openjdk/adoptopenjdk8

Step 3: Switch your terminal to use JDK 8

You need to update your shell profile to set JDK 8 as the default for terminal sessions:

  • For Bash users: Open your ~/.bash_profile file in a text editor, add this line, then save:
    export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
    
    Reload the profile to apply changes:
    source ~/.bash_profile
    
  • For Zsh users (default on macOS Catalina and newer): Open ~/.zshrc, add the same line above, save, then run:
    source ~/.zshrc
    

Step 4: Verify the switch worked

Run java -version again—you should see output confirming Java 1.8.x is now active.

Step 5: Re-run your React Native build

Now try launching your app again:

react-native run-android

This should resolve the version mismatch and let the build complete successfully.

Quick Extra Tips

If you still run into issues, double-check your project's android/build.gradle file to ensure the Gradle plugin version isn't requiring a newer JDK than 8 (most React Native projects targeting standard Android versions stick to JDK 8 compatibility). Also, if you use Android Studio to build, make sure its JDK setting (File > Project Structure > SDK Location > JDK Location) points to JDK 8 too.

内容的提问来源于stack exchange,提问作者Mudassar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:19:18