Skip to content

@react-native/popup-menu-android causes build failure on android: build.gradle.kts Unresolved reference: libs #49112

@shanebrowncs

Description

@shanebrowncs

Description

As of RN 0.74 UIManagerModule.showPopupMenu was deprecated and replaced with <PopupMenuAndroid> and placed into the @react-native/popup-menu-android package. When installing this package into a fresh 0.77 project and running yarn android, the build of this package fails with the error:

  Line 10:   alias(libs.plugins.android.library)
                   ^ Unresolved reference: libs

  Line 11:   alias(libs.plugins.kotlin.android)
                   ^ Unresolved reference: libs

I have provided an example and stacktrace. Please let me know if there is any more information needed.

Thanks.

Steps to reproduce

  1. Create fresh project with npx @react-native-community/cli@latest init AwesomeProject
  2. Install @react-native/popup-menu-android
  3. Run yarn android
  4. See build failure

React Native Version

0.77.0

Affected Platforms

Runtime - Android

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: Linux 6.12 Arch Linux
  CPU: (8) x64 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz
  Memory: 3.31 GB / 15.55 GB
  Shell:
    version: "5.9"
    path: /usr/bin/zsh
Binaries:
  Node:
    version: 20.18.2
    path: /usr/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/bin/yarn
  npm:
    version: 11.0.0
    path: /usr/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "35"
      - "35"
    Build Tools:
      - 35.0.0
    Android NDK: Not Found
IDEs:
  Android Studio: AI-242.23726.103.2422.12816248
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby:
    version: 3.3.5
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.0
    wanted: 0.77.0
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

info A dev server is already running for this project on port 8081.
info Installing the app...

> Configure project :react-native_popup-menu-android
10 actionable tasks: 10 executed

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 

e: file:///home/shane/react-native-popup-menu-android-build-error/ReproducerApp/node_modules/@react-native/popup-menu-android/android/build.gradle.kts:10:9: Unresolved reference: libs
e: file:///home/shane/react-native-popup-menu-android-build-error/ReproducerApp/node_modules/@react-native/popup-menu-android/android/build.gradle.kts:11:9: Unresolved reference: libs

FAILURE: Build failed with an exception.

* Where:
Build file '/home/shane/react-native-popup-menu-android-build-error/ReproducerApp/node_modules/@react-native/popup-menu-android/android/build.gradle.kts' line: 10

* What went wrong:
Script compilation errors:

  Line 10:   alias(libs.plugins.android.library)
                   ^ Unresolved reference: libs

  Line 11:   alias(libs.plugins.kotlin.android)
                   ^ Unresolved reference: libs

2 errors

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 11s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
e: file:///home/shane/react-native-popup-menu-android-build-error/ReproducerApp/node_modules/@react-native/popup-menu-android/android/build.gradle.kts:10:9: Unresolved reference: libs
e: file:///home/shane/react-native-popup-menu-android-build-error/ReproducerApp/node_modules/@react-native/popup-menu-android/android/build.gradle.kts:11:9: Unresolved reference: libs FAILURE: Build failed with an exception. * Where:
Build file '/home/shane/react-native-popup-menu-android-build-error/ReproducerApp/node_modules/@react-native/popup-menu-android/android/build.gradle.kts' line: 10 * What went wrong:
Script compilation errors: Line 10: alias(libs.plugins.android.library) ^ Unresolved reference: libs Line 11: alias(libs.plugins.kotlin.android) ^ Unresolved reference: libs 2 errors * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 11s.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproducer

https://github.com/shanebrowncs/react-native-popup-menu-android-build-error

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions