question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android Studio gives a warning when compiling project.

See original GitHub issue

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
                }
            }
        }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:12
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ValcasaraBryancommented, Jan 27, 2021

Hello I have same error, with gradle-6-8-all and react-native-reanimated@1.13.2, I just now do eject my project from expo, I have react-native@0.63.4, 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

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
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

3reactions
akhan118commented, Jul 4, 2019

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 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve Android Studio warning Error? - Stack Overflow
It is giving you warning if you are using it please replace it with 'implementation' . So if you are not using 'compile'...
Read more >
Improve your code with lint checks - Android Developers
The lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, ...
Read more >
Suppress compiler warnings - Visual Studio - Microsoft Learn
Right-click on the project node, and choose Properties on the context menu. Or, select the project node and press Alt+Enter. Choose Build, and ......
Read more >
Android Studio:How to find errors in code after compile
When I compile my project, I get the output: --------------------------- Information:Compilation completed with 2 errors and 0 warnings in 6 ...
Read more >
How to fix "Trust Gradle Project?" warning in Android Studio.
Explained how to avoid the warning "Trust Gradle Project ?" in Android Studio and how to configure android projects directory to the trusted ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found