react-native-reanimated: Android build error "extra properties extension"

Description

Installed the latest version and tried to build it one Android studio following error occurred

Caused by: groovy.lang.MissingPropertyException: Cannot get property ‘react’ on extra properties extension as it does not exist

What went wrong: A problem occurred evaluating project ‘:react-native-reanimated’. Cannot get property ‘react’ on extra properties extension as it does not exist

1.9.0 version is shown the different error

node_modules/react-native-reanimated/android/build.gradle’ line: 99 A problem occurred configuring project ‘:react-native-reanimated’. Cannot add task ‘androidSourcesJar’ as a task with that name already exists

task androidSourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.srcDirs
        include '**/*.java'
 }

2.2.1 version is shown the different error

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

Where: Build file ‘/Users/apple/Desktop/meet-master/node_modules/react-native-reanimated/android/build.gradle’ line: 67

if(project.ext.react.enableHermes) {
    engine = "hermes"
}

What went wrong: A problem occurred evaluating project ‘:react-native-reanimated’. Cannot get property ‘react’ on extra properties extension as it does not exist

2: Task failed with an exception.

Where: Build file ‘/Users/apple/Desktop/meet-master/android/build.gradle’ line: 117

task jitsiAndroidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.source
}

What went wrong: A problem occurred configuring project ‘:react-native-reanimated’. Could not get unknown property ‘android’ for task ‘:react-native-reanimated:jitsiAndroidSourcesJar’ of type org.gradle.api.tasks.bundling.Jar.

Expected behavior

Android studio build it successfully

Actual behavior & steps to reproduce

npm i react-native-reanimated@2.2.2 or ant mentioned version Manually link the library for Android or auto-link the library Opening the project in native tool Android studio throws this build error

Facing the same errors while trying on a different version

  • 1.9.0, 2.0.0
  • 2.2.0, 2.2.4

Package versions

  • React Native: 0.63.4
  • React Native Reanimated: 2.0.0, 2.2.0, 2.2.1, 2.2.4
  • NodeJS: 14.17.6
  • Xcode: 12 iOS SDK 14.2
  • Java & Gradle: 1.8.0_271 & 6.8

Android SDK: API Levels: 23, 28, 29, 30, 31 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0

Affected platforms

  • Android
  • iOS

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 29 (2 by maintainers)

Most upvoted comments

@Adichilla I simply re-added the hermes settings to ‘android/app/build.gradle’ (with hermes disabled) and it fixed it. I think it comes with the default React project, but I removed it.

https://reactnative.dev/docs/hermes

Worked for me, thank you

@Adichilla It looks like you added

project.ext.react = [
    entryFile: "index.js",
    enableHermes: true
]

to the root ‘build.gradle’ file, not the ‘app/build.gradle’ file. Could that be the issue?

@adamonkey There is no code is available in the project build.gradle file So added manually and checked

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
    }
}

project.ext.react = [
    entryFile: "index.js",
    enableHermes: true
]

ext {

faced the same issue even after cleaning and Invalidate cache and restart

Caused by: groovy.lang.MissingPropertyException: Cannot get property 'react' on extra properties extension 
as it does not exist
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'android' 
for task ':react-native-reanimated:jitsiAndroidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.

I was trying to setup Jitsi ReactNative project - https://github.com/jitsi/jitsi-meet