Execution failed for task ':app:compileDebugJavaWithJavac'. React Native
See original GitHub issue- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
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`
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:11
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.
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…