Can't build or install React Native app after installing React Navigation

Viewed 190

I've just started building my first React Native app with minimal success. I've built my boilerplate code but now I want to add a separate screen to it. Cue React Navigation.

Having tried twice to install the module, I've not had much luck. I used both Facebook's documentation and the Getting Started guide from React Navigation themselves. Still no luck.

The error I get is something to do with the build.gradle file in my android folder. As per the Getting Started guide, I did add two lines into my dependencies area but this doesn't appear to have had any effect.

The error message is as follow:

Could not compile build file: 
'C:\Users\USERNAME\Documents\ReactNative\WasteAway\android\app\build.gradle\'
> startup failed
General error during semantic analysis: Unsupported class file major version 57

My dependencies in the build.gradle file are as follows:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

Am I missing something obvious here or have I skipped a step on the tutorials? I can't see where I'm going wrong here, folks. Any help is greatly appreciated.

1 Answers

Answering this since I've been advised on the solution: It looks like it was the version of the JDK that I was using which was causing problems. Strangely enough, I was using too new a version that was notoriously buggy. Uninstalling and reverting JDK1.8 solved my issues. Explanation here.

Related