React Native : Android - java.lang.UnsupportedClassVersionError



        Hi there, long time no see, I'm trouble with my full-time job, hobbies and etc. but never forgot anyone. First, i'm removed double topic in content page for clear view and not annoying by repeat sentence. Second, I'm starting new tech "React Native + Android".

        After i'm seeing one article about comparison with iOS (Objective-C) VS. React Native, the conclusion is cannot choose who win this test because some function iOS is better performance than React Native vice versa React Native better than iOS too.

        After i'm getting start React Native, it's need to install many package since "brew", "npm" and "react-native-cli" but if don't have brew, you must starting with install home brew via ruby base on your operating system. Many many error will lead you bore this thing but nothing can stop you. Get the great sword here: https://facebook.github.io/react-native/releases/next/docs/getting-started.html


        When you start create new project it's will take a time to download package again, then after you try connect Android phone via usb, don't forget turn on "USB Debugging", then i'm getting this error.

java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0


        What does it mean?, i'm not understand the number not relate to android sdk build-tools nor gradle build version BUT it's relate to gradle build, if you try to change android build-tools version, you wi'll get an error as above and if you try to change version higher this error will occur.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.android.support:appcompat-v7:25.0.2.
Searched in the following locations:



        In my gradle build file "~project/android/app/build.gradle", default version is...

compileSdkVersion 23
buildToolsVersion "23.0.1"
compile "com.android.support:appcompat-v7:23.0.1"

Do nothing, leave it default and open file "~project/android/build.gradle" find this line of code...

classpath 'com.android.tools.build:gradle:2.2.3'


change it to...
classpath 'com.android.tools.build:gradle:2.1.0'


      Re-compile via terminal command "react-native run-android" again, you should got BUILD SUCCESSFUL and first app will show on your phone. This below image is my first project in 10 minutes, sure you can do it better than me, i believed.


Test Environment
- Mac OSX Yosemite
- React Native
- Android SDK
- Lenovo A7000 (Android 6.0)

See you next post :)

Comments