react-native: React Native Android build fails with "package com.facebook.react.common.annotations.internal does not exist" on React Native 0.78
Description
I’m encountering a build failure when running yarn android for my React Native project (RN 0.78). The error occurs during :app:compileDebugJavaWithJavac and seems related to autogenerated New Architecture files. iOS builds work fine.
Error Snippet:
/Users/socon/Documents/Chinmay/socon-mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/ReactNativeApplicationEntryPoint.java:8: error: package com.facebook.react.common.annotations.internal does not exist import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
What I’ve tried:
./gradlew clean(succeeds but doesn’t resolve)./gradlew buildfails with same error- Toggled newArchEnabled in gradle.properties (both true/false)
- Cleared all caches (yarn cache clean, ./gradlew clean, deleted node_modules, android/.gradle, android/build)
- Verified React Native doctor (npx react-native doctor shows no issues)
Environment:
- React Native: 0.78.0
- React: 19.0.0
- Vision Camera: 4.6.4
- Gradle: 8.12 (with JDK 17)
Steps to reproduce
- Install All deps in package.json
- newArchEnable=true in build.gradle
- try to run
React Native Version
0.78.0
Affected Platforms
Build - MacOS
Areas
Other (please specify), Fabric - The New Renderer
Output of npx @react-native-community/cli info
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M2
Memory: 131.34 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.14.0
path: ~/.nvm/versions/node/v20.14.0/bin/node
Yarn:
version: 4.8.1
path: ~/.nvm/versions/node/v20.14.0/bin/yarn
npm:
version: 10.7.0
path: ~/.nvm/versions/node/v20.14.0/bin/npm
Watchman:
version: 2025.04.28.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/socon/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK:
API Levels:
- "33"
- "34"
- "35"
Build Tools:
- 30.0.3
- 34.0.0
- 35.0.0
- 35.0.1
- 36.0.0
System Images:
- android-28 | Google ARM64-V8a Play ARM 64 v8a
- android-29 | Google Play ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.3 AI-243.26053.27.2432.13536105
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.11
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/socon/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.78.0
wanted: 0.78.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.80.0 is now available (your project is running on v0.78.0).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.78.0&to=0.80.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
> Task :app:compileDebugJavaWithJavac FAILED
[Incubating] Problems report is available at: file:///Users/socon/Documents/Chinmay/socon-mobile/android/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.12/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
489 actionable tasks: 1 executed, 488 up-to-date
info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor
/Users/socon/Documents/Chinmay/socon-mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/ReactNativeApplicationEntryPoint.java:8: error: package com.facebook.react.common.annotations.internal does not exist
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler output below.
/Users/socon/Documents/Chinmay/socon-mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/ReactNativeApplicationEntryPoint.java:8: error: package com.facebook.react.common.annotations.internal does not exist
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
^
1 error
* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to get full insights.
BUILD FAILED in 7s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/socon/Documents/Chinmay/socon-mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/ReactNativeApplicationEntryPoint.java:8: error: package com.facebook.react.common.annotations.internal does not exist
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; ^
1 error FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler output below. /Users/socon/Documents/Chinmay/socon-mobile/android/app/build/generated/autolinking/src/main/java/com/facebook/react/ReactNativeApplicationEntryPoint.java:8: error: package com.facebook.react.common.annotations.internal does not exist import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; ^ 1 error * Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to get full insights. BUILD FAILED in 7s.
info Run CLI with --verbose flag for more details.
MANDATORY Reproducer
Not Present
Screenshots and Videos
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 16 (3 by maintainers)
Hi @Arthur-Noh ,
Thanks for your response.
As you suggested, I tried the following steps:
cd android ./gradlew clean cd .. rm -rf android/app/build/generatedHowever, I’m still encountering the same error. I’ve also searched extensively online but haven’t been able to find a working solution.
Would really appreciate any further guidance on this.
Thanks again!
Really nice to workaround this for now, but what really worked for me was replace the deprecated dependency
react-native-gradle-pluginfor the new one supported by react-native in newer version which is"@react-native/gradle-plugin": "0.76.9"in package.jsonMy react-native app has version 0.74.4, but apply version 0.76.9 to @react-native/gradle-plugin worked as well!
I hope it works!
Hi guys ! I know it’s very dummy way, but after build crushed, i’ve commented this line
and started building again watching this file. As soon as it was regenerated i’ve commented it again immediately, so it didn’t crush and continued build with success.
I tried the solution and it’s impact below and android build working fine
✅ Create a Stub for LegacyArchitectureLogger Since RN 0.77 auto-generates code assuming this class exists (but it was removed), manually add a stub to satisfy the compiler:
In your Android project, create a new file at: android/app/src/main/java/com/facebook/react/common/annotations/internal/LegacyArchitectureLogger.java
Add this minimal stub:
This satisfies the import in the auto-generated ReactNativeApplicationEntryPoint.java and allows your build to succeed. @cortinico @imjvictor98 @dppo @react-native-bot
What the Fix Does
The stub file we created provides empty implementations of two methods:
logFabricEnabled()- logs when the new Fabric renderer is enabledlogTurboModuleEnabled()- logs when TurboModules are enabledImpact Analysis
✅ Positive Impacts
Build Success:
Development Continuity:
No Runtime Impact:
⚠️ Potential Considerations
Missing Logging:
Future React Native Updates:
Architecture Detection:
newArchEnabled=false, this shouldn’t matter🔍 Technical Details
The issue occurred because:
LegacyArchitectureLogger📊 Risk Assessment
Risk Level: LOW
🎯 Recommendation
This fix is safe and recommended because:
The fix is essentially a “bridge” that lets React Native 0.77.0 work properly until the core team addresses this compatibility issue in future releases.
Thanks @cortinico
Added
@react-native/gradle-pluginThe issue solved then
The same problem can be solved by unifying the react-native version number
That happens because you’re using a wrong version of the
@react-native/gradle-plugin. You should be using the same version ofreact-native.Please check in your package.json if you have
@react-native/gradle-plugindeclared or useyarn whyto understand which version you’re loading inside yournode_modules.As you haven’t provided a reproducer, we can’t help you further
@ChinmayLale I tried removing the autolink-generated files and rebuilding, and it worked fine. Could you try the same steps on your side?
in react-native 0.79.4 also has same issue