question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on running react-native project : MainApplication.java:5: error: cannot find symbol import com.facebook.react.ReactApplication;

See original GitHub issue

I have created project using expo ie expo init helloworld then ejected it using expo eject.

And then I tried to run in emulator with yarn run android . I got the following error.

$ yarn run android yarn run v1.3.2 $ react-native run-android Scanning folders for symlinks in D:\gajurlab\helloworld\node_modules (25ms) JS server already running. Building and installing the app on the device (cd android && gradlew.bat installDebug)… Incremental java compilation is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE :app:prepareComFacebookFrescoDrawee081Library UP-TO-DATE :app:prepareComFacebookFrescoFbcore081Library UP-TO-DATE :app:prepareComFacebookFrescoFresco081Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipeline081Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipelineOkhttp081Library UP-TO-DATE :app:prepareComFacebookReactReactNative0201Library UP-TO-DATE :app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:bundleDebugJsAndAssets SKIPPED :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:5: error: cannot find symbol import com.facebook.react.ReactApplication; ^ symbol: class ReactApplication location: package com.facebook.react D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:6: error: cannot find symbol import com.facebook.react.ReactNativeHost; ^ symbol: class ReactNativeHost location: package com.facebook.react D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:14: error: cannot find symbol public class MainApplication extends Application implements ReactApplication { ^ symbol: class ReactApplication D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:16: error: cannot find symbol private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { ^ symbol: class ReactNativeHost location: class MainApplication D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:36: error: cannot find symbol public ReactNativeHost getReactNativeHost() { ^ symbol: class ReactNativeHost location: class MainApplication D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainActivity.java:5: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivi ty public class MainActivity extends ReactActivity { ^ D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:16: error: cannot find symbol private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { ^ symbol: class ReactNativeHost location: class MainApplication D:\gajurlab\helloworld\android\app\src\main\java\com\mynewproject\MainApplication.java:35: error: method does not override or implement a method from a supertype @Override ^ 8 errors :app:compileDebugJavaWithJavac FAILED

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.

BUILD FAILED

Total time: 9.46 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/getting-started.html Done in 12.38s.

Info

$ react-native info Scanning folders for symlinks in D:\gajurlab\helloworld\node_modules (25ms)

Environment: OS: Windows 8.1 Node: 8.9.4 Yarn: 1.3.2 npm: 5.6.0 Watchman: Not Found Xcode: N/A Android Studio: Version 3.1.0.0 AI-173.4720617

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:20
  • Comments:36 (2 by maintainers)

github_iconTop GitHub Comments

80reactions
phorvichekacommented, Nov 22, 2018

I solved it by: change the line below in android/app/build.gradle file from implementation “com.facebook.react:react-native:+” // From node_modules to specific version of my react-native as in package.json implementation “com.facebook.react:react-native:0.57.5” // From node_modules

image

9reactions
brien-givenscommented, Jan 10, 2019

I had the same problem - adding the following block to allprojects.repositories in the project’s build.gradle fixed it for me:

maven {
    url "$rootDir/../node_modules/react-native/android"
}

Versions Android Studio: 3.4 Canary 10 gradle: 5.1 react-navive: 0.57.8

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native: error: cannot find symbol after upgrade
First: install all dependencies using yarn or npm;. Second: use the code below to link native dependencies on iOS and Android native code;...
Read more >
Java – React native: error: cannot find symbol after upgrade
C:\Users\user\gramic\android\app\src\main\java\com\shop\MainApplication.java:5: error: cannot find symbol import com.facebook.react.ReactApplication;
Read more >
How to fix this error I get when importing kotlin package into ...
I'm building a react native app that uses the ... android/app/src/main/java/com/rncamera0/MainApplication.java:16: error: cannot find symbol.
Read more >
error: cannot find symbol viewmanagerresolver ... - You.com
A "Cannot find symbol" error means that the compiler cannot do this. ... on running react-native project : MainApplication.java:5: error: cannot find symbol...
Read more >
Hippo - Execution failed for task - Higgs - SOBotics
... FILES/mob/first/android/app/src/main/java/com/practice/MainApplication.java:5: error: cannot find symbol import com.facebook.react.ReactApplication ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found