React-native-reanimated: Android Studio gives a warning when compiling project.

Created on 18 Mar 2019  ยท  18Comments  ยท  Source: software-mansion/react-native-reanimated

API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

REASON: Called from: /home/amol/Desktop/Accountant/node_modules/react-native-reanimated/android/build.gradle:87

line 87 is in android.libraryVariants.all;

Here is the gradle file

       def safeExtGet(prop, fallback) {
            rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
        }

        apply plugin: 'com.android.library'
        apply plugin: 'maven'

        android {
            compileSdkVersion safeExtGet('compileSdkVersion', 25)
            buildToolsVersion safeExtGet('buildToolsVersion', '25.0.2')

            defaultConfig {
                minSdkVersion safeExtGet('minSdkVersion', 16)
                targetSdkVersion safeExtGet('targetSdkVersion', 22)
                versionCode 1
                versionName "1.0"
            }
            lintOptions {
                abortOnError false
            }
        }

        repositories {
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                // Matches the RN Hello World template
                // https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/local-cli/templates/HelloWorld/android/build.gradle#L21
                url "$projectDir/../node_modules/react-native/android"
            }
            mavenCentral()
        }

        dependencies {
            implementation 'com.facebook.react:react-native:+'
        }

        def configureReactNativePom(def pom) {
            def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)

            pom.project {
                name packageJson.title
                artifactId packageJson.name
                version = packageJson.version
                group = "com.swmansion.reanimated"
                description packageJson.description
                url packageJson.repository.baseUrl

                licenses {
                    license {
                        name packageJson.license
                        url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
                        distribution 'repo'
                    }
                }

                developers {
                    developer {
                        id packageJson.author.username
                        name packageJson.author.name
                    }
                }
            }
        }

        afterEvaluate { project ->

            task androidJavadoc(type: Javadoc) {
                source = android.sourceSets.main.java.srcDirs
                classpath += files(android.bootClasspath)
                classpath += files(project.getConfigurations().getByName('compile').asList())
                include '**/*.java'
            }

            task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
                classifier = 'javadoc'
                from androidJavadoc.destinationDir
            }

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

            android.libraryVariants.all { variant ->
                def name = variant.name.capitalize()
              // This is line 87 `variant.javaCompile` something needs to change here.
                task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) {
                    from variant.javaCompile.destinationDir
                }
            }

            artifacts {
                archives androidSourcesJar
                archives androidJavadocJar
            }

            task installArchives(type: Upload) {
                configuration = configurations.archives
                repositories.mavenDeployer {
                    // Deploy to react-native-event-bridge/maven, ready to publish to npm
                    repository url: "file://${projectDir}/../android/maven"

                    configureReactNativePom pom
                }
            }
        }
๐Ÿ› build-or-config-issue

Most helpful comment

I think this has been fixed, I have "react-native-reanimated": "^1.1.0", and I'm no longer seeing it. Please update to the latest version .

All 18 comments

I'm getting the same error. My best guess is that gradle is out of date. The version needs to be updated here: https://github.com/kmagiera/react-native-reanimated/blob/master/android/build.gradle

Can you solve this problem? @ @guptaamol @IAmMarcellus

Nope not yet,
I am not familiar with groovy.

On Sun 28 Apr, 2019, 10:16 AM ๅคงๅ—ๅคด, notifications@github.com wrote:

Can you solve this problem? @ @guptaamol https://github.com/guptaamol
@IAmMarcellus https://github.com/IAmMarcellus

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kmagiera/react-native-reanimated/issues/215#issuecomment-487343650,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFJREFLEPOWF5X7ZOTKHYVLPSUT2VANCNFSM4G7GQAMQ
.

Same issue here

Same here as well.

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
Affected Modules: react-native-reanimated

you can use command: yarn add kmagiera/react-native-reanimated

Any updates on this? :-?

I think this has been fixed, I have "react-native-reanimated": "^1.1.0", and I'm no longer seeing it. Please update to the latest version .

I think this has been fix , I have "react-native-reanimated": "^1.1.0", and I'm no longer seeing it. Please update to the latest version .

Thank you @akhan118. It is fixed in this version.

Fixed in latest release.
@kmagiera This can be closed.

I am using react-native-animated: 1.9.0 and l have this issue ```
task ':react-native-reanimated:androidJavadoc'.

Javadoc generation failed
```

@lekeCoder, please provide some repro example and more detailed gradle logs (check verbose or debug options).

This is part of the error log

/Users/***/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java:4: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.ReadableMap;
                                ^
100 errors

> Task :react-native-reanimated:androidJavadoc FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
ReactNativeFirebase WARNING: NPM package '@react-native-firebase/auth' depends on '@react-native-firebase/app' v8.3.1 but found v8.4.5, this might cause build issues or runtime crashes.
ReactNativeFirebase WARNING: NPM package '@react-native-firebase/remote-config' depends on '@react-native-firebase/app' v8.4.0 but found v8.4.5, this might cause build issues or runtime crashes.

FAILURE: Build failed with an exception.

Did you run yarn install before compiling files? Seems like RN native code isn't present.

I am seeing this same issue of:
react-native-reanimated:androidJavadoc.

I am on Gradle 6.7, android build tools Gradle 4.0.0 and latest version of react-native-reanimated

Will try to get a stack trace of sorts in a bit.

I just started getting the same error. I'm not sure what I've changed, but I can no longer get my app running on android devices. npx react-naitive run-android results in the following:

info Done writing bundle output
info Done writing sourcemap output
info Copying 47 asset files
info Done copying assets

> Task :react-native-reanimated:androidJavadoc FAILED
/Users/[...stuff...]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:5: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.Arguments;
                                ^
/Users/[...stuff...]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:6: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.Callback;
                                ^
/Users/[...stuff...]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:7: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.GuardedRunnable;
                                ^
/Users/[...stuff...]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java:8: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;

...(plus a lot more similar errors)...

100 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-reanimated:androidJavadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/Users/[...stuff...]/node_modules/react-native-reanimated/android/build/tmp/androidJavadoc/javadoc.options'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 33s
2342 actionable tasks: 6 executed, 2336 up-to-date
error Failed to build the app. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew build -x lint
    at makeError (/Users/[...stuff...]/node_modules/execa/index.js:174:9)
error Command failed with exit code 1.

This is likely related to the missing RN Android library. See this comment for solution. If that doesn't help please create a repro repository, we can't debug it without testing it locally.

Hello I have same error, with gradle-6-8-all and [email protected], I just now do eject my project from expo, I have [email protected], I launch successfully on iOS but i can't do it on Android

RESPONSE

This is part of the error log

/Users/***/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java:4: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.ReadableMap;
                                ^
100 errors

> Task :react-native-reanimated:androidJavadoc FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
ReactNativeFirebase WARNING: NPM package '@react-native-firebase/auth' depends on '@react-native-firebase/app' v8.3.1 but found v8.4.5, this might cause build issues or runtime crashes.
ReactNativeFirebase WARNING: NPM package '@react-native-firebase/remote-config' depends on '@react-native-firebase/app' v8.4.0 but found v8.4.5, this might cause build issues or runtime crashes.

FAILURE: Build failed with an exception.

react-native -v

react-native-cli: 2.0.1
react-native: 0.63.4

package.json

{
  "scripts": {
    "start": "react-native start",
    "info": "react-native info",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/async-storage": "~1.12.0",
    "@react-native-community/cli": "^4.13.1",
    "@react-native-community/netinfo": "^5.9.7",
    "expo": "~40.0.0",
    "expo-asset": "~8.2.1",
    "expo-camera": "^10.0.0",
    "expo-clipboard": "^1.0.1",
    "expo-constants": "^9.3.5",
    "expo-device": "~2.4.0",
    "expo-image-picker": "^9.2.1",
    "expo-localization": "^9.1.0",
    "expo-location": "^10.0.0",
    "expo-media-library": "^11.0.0",
    "expo-notifications": "~0.8.2",
    "expo-permissions": "~10.0.0",
    "expo-splash-screen": "^0.8.1",
    "expo-status-bar": "^1.0.3",
    "expo-task-manager": "^8.6.0",
    "expo-updates": "~0.4.0",
    "jetifier": "^1.6.6",
    "jwt-decode": "^3.1.2",
    "lodash": "^4.17.20",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.32",
    "prop-types": "^15.7.2",
    "react": "16.13.1",
    "react-devtools": "^3.6.3",
    "react-dom": "16.13.1",
    "react-native": "^0.63.4",
    "react-native-calendars": "^1.940.0",
    "react-native-dash": "0.0.11",
    "react-native-elements": "^3.0.0-alpha.1",
    "react-native-extended-stylesheet": "^0.12.0",
    "react-native-flash-message": "^0.1.18",
    "react-native-gesture-handler": "~1.8.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.3",
    "react-native-map-link": "^2.7.19",
    "react-native-reanimated": "^1.13.2",
    "react-native-screens": "~2.15.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-svg": "12.1.0",
    "react-native-svg-charts": "^5.4.0",
    "react-native-unimodules": "^0.12.0",
    "react-native-vector-icons": "^7.1.0",
    "react-native-web": "~0.13.12",
    "react-native-webview": "^11.0.0",
    "react-navigation": "^4.4.3",
    "react-navigation-stack": "^1.10.3",
    "react-navigation-tabs": "^2.10.1",
    "react-redux": "^7.2.2",
    "react-refresh": "^0.8.3",
    "redux": "^4.0.5",
    "redux-actions": "^2.6.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-persist": "^6.0.0",
    "redux-persist-seamless-immutable": "^2.0.0",
    "redux-saga": "^1.1.3",
    "redux-toolkit": "^1.1.2",
    "seamless-immutable": "^7.1.4"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "babel-jest": "^25.2.6",
    "babel-preset-expo": "8.3.0",
    "jest": "^25.2.7",
    "react-test-renderer": "^16.13.1"
  },
  "private": true,
  "name": "NAME",
  "version": "1.0.0"
}

Error Stack

[...]

/Users/[path]/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java:4: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.ReadableMap;
                                ^
100 errors
Note: /Users/[path]/android/app/src/debug/java/com/[name-project]/ReactNativeFlipper.java uses or overrides a deprecated API
Note: Recompile with -Xlint:deprecation for details.
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-reanimated:androidJavadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/Users/[path]/node_modules/react-native-reanimated/android/build/tmp/androidJavadoc/javadoc.options'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 48s

I launched react-native doctor

 โœ“ Node.js
 โœ“ yarn
 โœ“ Watchman - Used for watching changes in the filesystem when in development mode

Android
 โœ“ JDK
 โœ“ Android Studio - Required for building and installing your app on Android
 โœ“ Android SDK - Required for building and installing your app on Android
 โœ“ ANDROID_HOME

iOS
 โœ“ Xcode - Required for building and installing your app on iOS
 โœ“ CocoaPods - Required for installing iOS dependencies
 โœ“ ios-deploy - Required for installing your app on a physical device with the CLI

Errors:   0
Warnings: 0
Common
 โœ“ Node.js
 โœ“ yarn
 โœ“ Watchman - Used for watching changes in the filesystem when in development mode

Android
 โœ“ JDK
 โœ“ Android Studio - Required for building and installing your app on Android
 โœ“ Android SDK - Required for building and installing your app on Android
 โœ“ ANDROID_HOME

iOS
 โœ“ Xcode - Required for building and installing your app on iOS
 โœ“ CocoaPods - Required for installing iOS dependencies
 โœ“ ios-deploy - Required for installing your app on a physical device with the CLI

Errors:   0
Warnings: 0

I am on MacBookPro, Darwin Kernel Version 19.6.0, macOS Catalina 10.15.7

Someone can help me please

Edit:
I solved my problem
I used this commande ./gradlew clean in android repository
In android/gradle.properties I have this options :

org.gradle.jvmargs=-Xmx4096M -XX:MaxPermSize=1024M -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
FLIPPER_VERSION=0.54.0
-Pandroid.debug.obsoleteApi=true

and I launch react-native run-androidcommand without option --deviceId=${id_device}
because this option make error --deviceId=${id_device}

I hope this comment will help you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrousavy picture mrousavy  ยท  3Comments

robertgonzales picture robertgonzales  ยท  3Comments

bdrobinson picture bdrobinson  ยท  3Comments

alexfov picture alexfov  ยท  3Comments

hosseinmd picture hosseinmd  ยท  3Comments