error: package com.facebook.react.defaults does not exist

This issue has been tracked since 2022-09-21.

Description

after upgrading react native from 0.69.5 to 0.70.1

I am getting this error when building the android app

---/android/app/src/main/java/com/applicationMainApplication.java:14: error: package com.facebook.react.defaults does not exist
import com.facebook.react.defaults.DefaultNativeEntryPoint;
^
---/android/app/src/main/java/com/applicationMainApplication.java:15: error: package com.facebook.react.defaults does not exist
import com.facebook.react.defaults.DefaultReactNativeHost;
^
---/android/app/src/main/java/com/applicationMainActivity.java:4: error: package com.facebook.react.defaults does not exist
import com.facebook.react.defaults.DefaultReactActivityDelegate;
^
---/android/app/src/main/java/com/applicationMainApplication.java:24: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(
^
symbol: class DefaultReactNativeHost
location: class MainApplication

Version

0.70.1

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 12.2.1
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 387.32 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 13.3/13E113 - /usr/bin/xcodebuild
Languages:
Java: 11.0.8 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.1 => 0.70.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

upgrade from react native 0.69.5 to 0.70.1

Snack, code example, screenshot, or link to a repository

....

cortinico wrote this answer on 2022-09-22

I am getting this error when building the android app

---/android/app/src/main/java/com/applicationMainApplication.java:14: error: package com.facebook.react.defaults does not exist import com.facebook.react.defaults.DefaultNativeEntryPoint; ^ ---/android/app/src/main/java/com/applicationMainApplication.java:15: error: package com.facebook.react.defaults does not exist import com.facebook.react.defaults.DefaultReactNativeHost; ^ ---/android/app/src/main/java/com/applicationMainActivity.java:4: error: package com.facebook.react.defaults does not exist import com.facebook.react.defaults.DefaultReactActivityDelegate; ^ ---/android/app/src/main/java/com/applicationMainApplication.java:24: error: cannot find symbol private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost( ^ symbol: class DefaultReactNativeHost location: class MainApplication

Hey @omars94,
Thanks for reporting this issue,

Have you manually copied files from the template/ folder on React Native?
If so, I believe you copied the files from the wrong version.

You should copy them from 0.70-stable:
https://github.com/facebook/react-native/blob/0.70-stable/template/android/app/src/main/java/com/helloworld/MainApplication.java

If so, can you also share the content of your applicationMainApplication.java?

More Details About Repo
Owner Name facebook
Repo Name react-native
Full Name facebook/react-native
Language JavaScript
Created Date 2015-01-09
Updated Date 2022-10-03
Star Count 105144
Watcher Count 3666
Fork Count 22469
Issue Count 2232

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date