Error on running react-native project : MainApplication.java:5: error: cannot find symbol import com.facebook.react.ReactApplication;
See original GitHub issueI 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:
- Created 5 years ago
- Reactions:20
- Comments:36 (2 by maintainers)
Top GitHub Comments
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
I had the same problem - adding the following block to
allprojects.repositories
in the project’sbuild.gradle
fixed it for me:Versions Android Studio: 3.4 Canary 10 gradle: 5.1 react-navive: 0.57.8