I am relatively new to react-native and gradle (coding in general). I am trying to run my code on my phone but I keep getting the following error: Execution failed for task ':app:compileDebugJavawithJavac'
.
I have tried looking for a solution but none of it worked. I have tried:
reinstalling the environmental variable JAVA_HOME,
ran gradlew clean, and
also did npm install in my android folder but nothing worked.
Here is the response I've gotten:
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainApplication.java:5: error: cannot find symbol
import com.facebook.react.ReactApplication;
^
symbol: class ReactApplication
location: package com.facebook.react
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
^
symbol: class ReactNativeHost
location: package com.facebook.react
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainApplication.java:14: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
^
symbol: class ReactApplication
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainApplication.java:36: error: cannot find symbol
public ReactNativeHost getReactNativeHost()
^
symbol: class ReactNativeHost
location: class MainApplication
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainActivity.java:5: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
^
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
C:\Users\Saint\OneDrive\Desktop\Important Stuff\Programming stuff\react\Calendar\android\app\src\main\java\com\Calendar\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 3s
13 actionable tasks: 1 executed, 12 up-to-date
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
Thank you for your help!
EDIT: Here is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}