microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.99k stars 1.48k forks source link

Android build fails: Incorrect package found in source AndroidManifest.xml (Gradle 8) #2759

Closed aminedf closed 1 month ago

aminedf commented 2 months ago

Since we upgraded gradle version to > 8.0, we cannot achieve a successful build because of react-native-code-push@8.3.1, we cannot update to 9.0.0 which works fine but requires iOS > 15.

We tried to remove the package attribute from AndroidManifest as we did with other dependencies but it does not work here.

Steps to Reproduce

  1. Google Play requires now SDK 34
  2. We Upgraded Gradle to 8.5.0 (distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip)
  3. Build fails because of react-native-code-push

Expected Behavior

Correct build

Actual Behavior

What actually happens?

Incorrect package="com.microsoft.codepush.react" found in source AndroidManifest.xml
Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
Recommendation: remove package="com.microsoft.codepush.react" from the source AndroidManifest.xml:

Environment

(The more info the faster we will be able to address it!)

DordeDimitrijev commented 2 months ago

Hello @aminedf thank you for reaching out! As a workaround as you already mentioned you need to remove the package attribute from manifest but you need to pass it into build.gradle of rn-code-push like this. Let me know if this workaround does the job for you.

aminedf commented 2 months ago

Thanks for your quick answer @DordeDimitrijev! 🙌🏻

We already have a postinstall script that moves the package attribute from AndroidManifest.xml to app/build.gradle as namespace for most of our dependencies but, for some reason, our build crashes in an early stage when we include rn-code-push.

The error that we receive with rn-code-push@8.3.1 manipulating its AndroidManifest.xml and build.gradle is this one:

BUILD FAILED in 12s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 1 FAILURE: Build failed with an exception. * Where:
Settings file '/.../android/settings.gradle' line: 3 * What went wrong:
A problem occurred evaluating settings 'android'.
> ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 1 * 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 12s.

Confirmed that upgrading rn-code-push to 9.0.0 makes that everything work fine.

DordeDimitrijev commented 1 month ago

I would say that your postinstall script works fine when it comes to fixing the issue with namespace since you no longer have this error, right?

Incorrect package="com.microsoft.codepush.react" found in source AndroidManifest.xml Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported. Recommendation: remove package="com.microsoft.codepush.react" from the source AndroidManifest.xml:

As for the issue you experience now it doesn't loook like it's related to the previous one rather some miscofniguration inside your setttings.gradle file, could you check that you've setup your rn app properly with rncp according to the docs here

DordeDimitrijev commented 1 month ago

Closing due to inactivity.