简体   繁体   中英

Task :react-native-firebase:compileReleaseJavaWithJavac FAILED

I clone my own repo. project in on react native, I installed node modules and set Jdk8 as per requirements of my project. Then i run my project using react-native run-android. show me error

Task :react-native-firebase:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-firebase:compileReleaseJavaWithJavac'.
> Could not create service of type GeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

* 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

BUILD FAILED in 1m 3s
13 actionable tasks: 2 executed, 11 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug
    at checkExecSyncError (child_process.js:601:13)
    at Object.execFileSync (child_process.js:621:13)
    at runOnAllDevices (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
    at buildAndRun (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
    at isPackagerRunning.then.result (/Volumes/Transcend/Emjoy/admin_panel_app_emjoy/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

My version of react-native,react-native-cli, react-native-firebase all packages is the same as a project required.

If you are using React-Native 0.60+ make sure to use.

npx jetify

From the project root directory.

This a very absurd issue with react native 0.60+ coz it wants the jetifier to be installed.

So i resolved it by first installing jetifier , you can use yarn or npm.

yarn add jetifier 

or

npm jetifier 

then after that you should execute npx jetify

Probably a late answer but I ran into the same error today and this is how i resolved it

before running ./gradlew assembleRelease you need to run npx jetify

The above command converts android.support.v4.app.* package into androidx.core.app.* which helps build to be compile.

As the other answers stated for react native 0.60+ you should have jetifier installed

    npm jetifier

I have it set as a postinstall script in my package.json, so this is done everytime npm install is done.

     "postinstall": "npx jetify"

In addition, in your app/build.gradle make sure you have

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

dependencies {
    ...

    if (enableHermes) {
        // for RN 0.60.x
        def hermesPath = "../../node_modules/hermesvm/android/"


        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

Simple use below commands.Enable jetifier in react-native project.

1. npm install --save-dev jetifier/yarn add --dev jetifier

2. npx jetify/yarn run jetify

3. npx react-native run-android.

You can fix this issue like this:

  1. Install Jetifier:

    yarn add --dev jetifier

  2. Launch Jetifier via this command:

    yarn run jetify

Here we go !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM