Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution failed for task ':app:compileDebugJavaWithJavac'. React Native #21722

Closed
3 tasks
pateldaivik opened this issue Oct 11, 2018 · 11 comments
Closed
3 tasks
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@pateldaivik
Copy link

pateldaivik commented Oct 11, 2018

Environment

OS: Windows 10
Node: 8.10.0
Yarn: 1.9.4
npm: 6.4.1
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4819257
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz => 0.55.4.

Description

I created a new project with "create-react-native-app" and then ejected it to plain react native project. When i try to run "react-native run-android" command i get build failed with error Execution failed for task ':app:compileDebugJavaWithJavac'.

Reproducible Demo

I executed following commands.
create-react-native-project [projectname]
cd [projectname]
npm run eject
react-native run-android

The result output is as follows.

`F:\react\xdceconverter>react-native run-android
Scanning folders for symlinks in F:\react\xdceconverter\node_modules (118ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Task :app:compileDebugJavaWithJavac
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:5: error: cannot find symbol
import com.facebook.react.ReactApplication;
^
symbol: class ReactApplication
location: package com.facebook.react
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
^
symbol: class ReactNativeHost
location: package com.facebook.react
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:14: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
^
symbol: class ReactApplication
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:36: error: cannot find symbol
public ReactNativeHost getReactNativeHost() {
^
symbol: class ReactNativeHost
location: class MainApplication
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainActivity.java:5: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
^
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
F:\react\xdceconverter\android\app\src\main\java\com\xdceconverter\MainApplication.java:35: error: method does not override or implement a method from a supertype
@OverRide
^
8 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • 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 41s
18 actionable tasks: 5 executed, 13 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`

@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

@pateldaivik
Copy link
Author

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

I have provided the environment details which are obtained after running react-native info in the environment section.

@PtitNome
Copy link

I have the same issue, here are my infos:

Environment:
OS: Windows 10
Node: 8.12.0
Yarn: Not Found
npm: 6.4.1
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz => 0.55.4

I started with a CRNA that I ejected. I also ran a npm install -g react-native-git-upgrade that didn't change anything to the errors messages.

The only difference I have is the warning about the compile keyword taht I already replaced with implementation.

I can provide my gradle files if you think it could be useful!

@sopedro
Copy link

sopedro commented Oct 28, 2018

Same Issue here on MacOS:

Environment:
OS: macOS 10.14
Node: 10.6.0
Yarn: Not Found
npm: 6.1.0
Watchman: Not Found
Xcode: Xcode 10.0 Build version 10A255
Android Studio: 3.2 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

@KevinGeorge
Copy link

KevinGeorge commented Nov 14, 2018

Same issue for me. i ejected my project from CRNA too.
However when i create a new react-native project and run-android it works.

OS: Windows 10
Node: v10.7.0
npm : 6.1.0
Android studio 3.2.1
react : 16.5.0
react-native-cli: 2.0.1
react-native: 0.57.1

EDIT :
It looks like i've corrected it, i had as a dependency in my package.json :
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",

I changed it to :
"react-native": "0.57.5",

and run "npm install", and now it works...

@elstoutenburg
Copy link

elstoutenburg commented Nov 15, 2018

I've been dealing with this issue for a while now, resorted to react-native-init but changing to "react-native": "0.57.5", fixed it for me. Thanks.

@archit6204
Copy link

"react-native": "0.57.5",

this works for me

thanks a lot

@shashank-shark
Copy link

Step 1: Delete node_modules folder.
Step 2: run "yarn install" without quotes.
Step 3: Then run, "react-native run-android".

If the above steps fails, then change react-native version to 0.57.5 in package.json file and then repeat the steps 1,2,3.

@elozev

This comment has been minimized.

@JoaoVitorViana
Copy link

React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 568.49 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.11.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.0, 28.0.0, 28.0.1, 28.0.2, 28.0.3
API Levels: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
@types/react: ^16.4.1 => 16.4.7
@types/react-native: ^0.55.22 => 0.55.28
react: 16.8.3 => 16.8.3
react-native: 0.59.0 => 0.59.0
npmGlobalPackages:
react-native-cli: 2.0.1

@elozev
Copy link

elozev commented Oct 10, 2019

Try migrating to AndroidX and then follow the steps from above.

@facebook facebook locked as resolved and limited conversation to collaborators Dec 20, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants