Skip to content

fix: stop an app's codegenConfig from hijacking this library's codegen - #201

Merged
floyd-soomgo merged 2 commits into
masterfrom
refactor/flatten-android-gradle-module
Sep 17, 2026
Merged

floyd-soomgo merged 2 commits into
masterfrom
refactor/flatten-android-gradle-module

Conversation

@floyd-soomgo

@floyd-soomgo floyd-soomgo commented Sep 17, 2026

Copy link
Copy Markdown
Member

Problem

When an app adds a TurboModule of its own and puts codegenConfig in its root package.json, that config is applied to this library's codegen instead of the library's own. NativeCodePushSpec is never generated, the app's spec is written into the library's build directory, and compilation fails:

node_modules/@bravemobile/react-native-code-push/android/app/src/main/java/
com/microsoft/codepush/react/CodePushNativeModule.java:44:
error: cannot find symbol
public class CodePushNativeModule extends NativeCodePushSpec {

The react-native gradle plugin's findPackageJsonFile() looks for ../package.json next to the gradle module first and falls back to the app root when that file is missing. This library's module sat at android/app, so the first lookup never resolved and the app root was always read. It only stayed invisible while apps had no codegenConfig of their own.

Fix

The gradle module now lives at android/. The first lookup resolves to the library's own package.json, which already carries the correct codegenConfig. No second copy of the config is introduced, and this is the layout most React Native libraries already use.

A separate commit removes the standalone gradle setup, which had stopped working long ago: the wrapper pinned Gradle 2.4, the buildscript classpath pinned AGP 1.3.0, gradle.properties was in a subproject directory where Gradle never reads it, and Android unit tests run through an example app. None of those files were reachable from any build.

Upgrading

An existing app holds an autolinking cache pointing at the old path, so the first build after upgrading fails:

Configuring project ':bravemobile_react-native-code-push' without an existing directory is not allowed.
The configured projectDirectory '.../react-native-code-push/android/app' does not exist

Deleting these two directories clears it:

android/build/generated/autolinking
android/app/build/generated/autolinking

Nothing else changes for consumers. The gradle project name stays :bravemobile_react-native-code-push because it is derived from the npm package name, and the apply path for codepush-export.gradle is untouched.

Verification

codegen, Java compilation, unit tests and the CMake native build all pass on the RN 0.77.3, 0.80.3, 0.83.2 and 0.86.0 example apps, covering both ends of the supported range.

The reproduction case was checked on the lowest and highest versions: with codegenConfig present in the app root, NativeCodePushSpec.java is generated for the library and the app's own spec is generated for the app module, each in its own place.

@floyd-soomgo
floyd-soomgo force-pushed the refactor/flatten-android-gradle-module branch from 34d9cf5 to 727b3b5 Compare September 17, 2026 11:52
@floyd-soomgo floyd-soomgo changed the title refactor: flatten the android gradle module to android/ fix: stop an app's codegenConfig from hijacking this library's codegen Sep 17, 2026
@floyd-soomgo
floyd-soomgo merged commit 622e8c3 into master Sep 17, 2026
2 checks passed
@floyd-soomgo
floyd-soomgo deleted the refactor/flatten-android-gradle-module branch September 17, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant