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

This issue has been created 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?

cortinico wrote this answer on 2022-10-03

Hey @omars94
I'm closing this issue due to lack of response
Feel free to re-open it or create a new issue if the problem persists.
Thanks

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-07
Star Count 105180
Watcher Count 3671
Fork Count 22481
Issue Count 2230

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Investigate adding reserve prices to UserTransaction entities 0 2022-06-15 2022-09-06
Panel in startup window with files that can be recovered when PixiEditor crashed 2 2022-02-16 2022-09-22
Shared tool settings are broken 3 2022-02-01 2022-09-22
Shortcuts stop working sometimes 0 2022-02-17 2022-09-22
layer.MaxWidth and layer.MaxHeight aren't set when the layers are loaded from file 0 2022-02-17 2022-09-22
Show image in taskbar doesn't work on Windows 11 0 2022-02-16 2022-09-26
One Authentication one client 5 2021-05-04 2022-09-21
Problems installing Ubuntu 18.04 4 2021-04-28 2022-08-23
NDB() NetlinkError: (22, 'Invalid argument') when adding rules. 2 2022-04-05 2022-09-22
Where is Viterbi algorithm in your code? 1 2022-02-21 2022-10-06
Download of pretrained brox flow trained model weights 3 2022-02-21 2022-08-04
Last column is partially cut 0 2021-07-21 2022-10-03
Some Crucial mistakes .. 0 2022-05-08 2022-09-06
Correct "Renaming Packages" section from the docs. 1 2022-06-07 2022-09-15
update_firmware_using_catalog.py does not initiate the update job 4 2021-06-01 2022-09-21
Add-DeviceToStaticGroup.ps1 3 2021-06-22 2022-09-21
getPair call via Ethers.Contract does not return a pair address 5 2022-09-26 2022-10-07
idpiframe_initialization_failed" 1 2021-08-09 2022-08-27
Tour step placement is not working properly 2 2022-01-31 2022-09-20
noise_meter (audio_streamer) error: android.media.AudioRecord.native_read_in_short_array(AudioRecord.java) 0 2022-09-15 2022-10-04
[health ^4.1.1] HealthDataPoint.fromJson(json) cannot process JSON data of WORKOUT type from HealthKit. 0 2022-09-16 2022-10-04
[Windows] High DPI Displays and scale factor != 100% 1 2021-04-27 2022-08-31
htmlToDraft ignores style attribute 0 2022-03-31 2022-03-31
How to return #text nodes as unstyled content block? 0 2022-02-03 2022-03-31
Fix vulnerabilities reported by Trivy scanner 1 2022-04-29 2022-09-20
Improve touchscreen support for OSs without a native input 0 2021-06-02 2022-09-26
`show-names` text color is inconsistent 0 2021-10-02 2022-08-07
[Meta] What's going on with the performance of the website? 0 2022-05-25 2022-09-18
Di Laporan Penduduk Bulanan bedakan keluarga datang dengan keluarga baru lainnya 10 2022-07-25 2022-08-22
Changes of today 2021-10-26 0 2021-10-26 2022-09-22
Pystan does not accept length-zero data vectors 3 2021-05-25 2022-10-04
MDFCs are not castable from Uba Mask 7 2021-09-05 2022-09-17
End Code and Start Code Improvements 7 2018-08-14 2022-10-05
Set the Seccomp profile 2 2022-07-05 2022-09-19
It takes more than 1 min to change the code lens after deleting the linked "childTemplate.json" file 1 2021-04-15 2022-09-27
.jump() broke 6 2021-08-29 2021-11-11
argoCD resource events impacts to etcd db size 0 2022-09-06 2022-10-03
Possibility to create dynamic project context variables to access in jobs 2 2022-05-31 2022-10-02
Remove reservations from Devices 2 2020-03-03 2022-09-05
dep-check: Make it simpler to declare packages/versions across profile versions 1 2022-01-27 2022-09-30
data-value and data-text in from html example 9 2022-09-15 2022-09-29
psycopg/types/enum.py release date ? 2 2022-07-02 2022-10-05
PodSelector for NodeDrainInput 3 2022-03-14 2022-09-16
Retrieve feature checks for all sites in a single request 2 2022-04-07 2022-09-26
Social Links Block: Add Steam Icon as a Supported Social Icon 0 2022-02-27 2022-07-24
Stepper: Footer bar hides part of pages on mobile 0 2022-04-07 2022-09-12
Stepper: courses page maintains previous page scrolling on mobile 0 2022-04-07 2022-10-03
password confirmation missing in verification 1 2022-03-17 2022-09-30
Broaden compilation linting 0 2022-07-15 2022-09-25
Unexpected use of reserved word 'class'. 5 2022-01-31 2022-09-27