react / react/react-native

Autolinking android regression

未关闭
#55,653 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

API: Linking Impact: Regression Needs: Triage :mag: Platform: Android
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

In React Native 0.84, the autolinking Gradle plugin (GeneratePackageListTask.kt) fails to generate correct fully qualified class names (FQCNs) when a library registers multiple React packages via react-native.config.js. Only the first package gets resolved; subsequent packages are emitted as bare class names with no import or qualification, causing a compilation error.

  • React Native: 0.84.0
  • Affected plugin: @react-native/gradle-pluginGeneratePackageListTask.kt
  • Affected library (example): react-native-appsflyer@6.17.8

I think the bug was introduced here https://github.com/facebook/react-native/pull/54736/changes

Steps to reproduce

Any library that registers multiple packages in its react-native.config.js will trigger this:

// node_modules/react-native-appsflyer/react-native.config.js
module.exports = {
  dependency: {
    platforms: {
      android: {
        packageImportPath: [
          'import com.appsflyer.reactnative.RNAppsFlyerPackage;',
          'import com.appsflyer.reactnative.PCAppsFlyerPackage;',
        ].join('\n'),
        packageInstance: [
          'new RNAppsFlyerPackage()',
          'new PCAppsFlyerPackage()',
        ].join(',\n'),
      },
    },
  },
};
Expected generated PackageList.java
// react-native-appsflyer
new com.appsflyer.reactnative.RNAppsFlyerPackage(),
new com.appsflyer.reactnative.PCAppsFlyerPackage(),
Actual generated PackageList.java
// react-native-appsflyer
new com.appsflyer.reactnative.RNAppsFlyerPackage(),
new PCAppsFlyerPackage(),
React Native Version

0.84.0

Affected Platforms

Other (please specify), Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 26.3
  CPU: (12) arm64 Apple M3 Pro
  Memory: 5.38 GB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.11.1
    path: ~/.asdf/installs/nodejs/24.11.1/bin/node
  Yarn:
    version: 4.12.0
    path: ~/.asdf/installs/nodejs/24.11.1/bin/yarn
  npm:
    version: 6.14.16
    path: ~/Desktop/repositories/g1-monorepo/node_modules/.bin/npm
  Watchman:
    version: 2025.03.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/marian.iordache/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.2
      - iOS 26.2
      - macOS 26.2
      - tvOS 26.2
      - visionOS 26.2
      - watchOS 26.2
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
      - "35"
      - "36"
      - "36"
    Build Tools:
      - 34.0.0
      - 35.0.0
      - 35.0.1
      - 36.0.0
    System Images:
      - android-30 | Google APIs ARM 64 v8a
      - android-30 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.28238.7.2523.14688667
  Xcode:
    version: 26.2/17C52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 3.4.4
    path: /Users/marian.iordache/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/marian.iordache/Desktop/repositories/ReproducerAutolinking/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:60: error: cannot find symbol
new PCAppsFlyerPackage(),
    ^
  symbol:   class PCAppsFlyerPackage
  location: class PackageList
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/marian.iordache/Desktop/repositories/ReproducerAutolinking/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:60: error: cannot find symbol
  new PCAppsFlyerPackage(),
      ^
    symbol:   class PCAppsFlyerPackage
    location: class PackageList
  1 error

* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to generate a Build Scan (Powered by Develocity).

BUILD FAILED in 8s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/marian.iordache/Desktop/repositories/ReproducerAutolinking/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:60: error: cannot find symbol
new PCAppsFlyerPackage(), ^ symbol: class PCAppsFlyerPackage location: class PackageList
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/marian.iordache/Desktop/repositories/ReproducerAutolinking/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:60: error: cannot find symbol new PCAppsFlyerPackage(), ^ symbol: class PCAppsFlyerPackage location: class PackageList 1 error * Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to generate a Build Scan (Powered by Develocity). BUILD FAILED in 8s.
info Run CLI with --verbose flag for more details.
MANDATORY Reproducer

https://github.com/Summys/ReproducerAutolinking

Screenshots and Videos

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 @react-native/gradle-plugin 中的 GeneratePackageListTask.kt 开始,并运行必需的 ReproducerAutolinking 项目,以检查生成的 PackageList.java。跟踪多个 packageImportPath 条目的处理;完成的标准是每个已注册的 package 都在生成的文件中使用完整限定名,并且 Android 构建成功。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, kotlin, react-native
领域
build-system, mobile
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
描述清楚
新手友好度
74/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。