2

When I run react-native run-android, i get the following error; I am setting it up to run on a device.

:app:compileDebugJava
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactApplication;
                         ^
  symbol:   class ReactApplication
  location: package com.facebook.react
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:8: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
                         ^
  symbol:   class ReactNativeHost
  location: package com.facebook.react
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:15: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
                                                            ^
  symbol: class ReactApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:17: error: cannot find symbol
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                ^
  symbol:   class ReactNativeHost
  location: class MainApplication
/Users/hello/MediaFire/apps/v/android/app/src/main/java/com/test2/MainApplication.java:32: error: cannot find symbol
  public ReactNativeHost getReactNativeHost() {
         ^
  symbol:   class ReactNativeHost
  location: class MainApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainActivity.java:6: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
       ^
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:17: error: cannot find symbol
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                                                       ^
  symbol:   class ReactNativeHost
  location: class MainApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:31: error: method does not override or implement a method from a supertype
  @Override
  ^
8 errors
:app:compileDebugJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> 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.

BUILD FAILED

Total time: 10.738 secs
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/android-setup.html
0

2 Answers 2

0

I fixed this issue with react-native upgrade

Reference: Overload119's answer

Sign up to request clarification or add additional context in comments.

Comments

0

Check the build.gradle(Project) file in android :

    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }

This line may be missing, add this under the repositories , it should look like this :

allprojects {

    repositories {
        mavenLocal()
        jcenter()
        google()


        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.