Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RN CLI relies on deprecated Package attribute in manifest file #1721

Closed
mqueiroz1995 opened this issue Oct 20, 2022 · 4 comments · Fixed by #1727
Closed

RN CLI relies on deprecated Package attribute in manifest file #1721

mqueiroz1995 opened this issue Oct 20, 2022 · 4 comments · Fixed by #1727

Comments

@mqueiroz1995
Copy link

Environment

info Fetching system and libraries information...
System:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M1
    Memory: 86.08 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - /var/folders/43/qlcypx4949v_41z_dsd_5dhh0000gp/T/yarn--1666297597926-0.7280508690523817/node
    Yarn: 1.22.19 - /var/folders/43/qlcypx4949v_41z_dsd_5dhh0000gp/T/yarn--1666297597926-0.7280508690523817/yarn
    npm: 6.14.17 - ~/REDACTED/node_modules/.bin/npm
    Watchman: 2022.09.19.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /REDACTED/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /REDACTED/.sdkman/candidates/java/current/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: ^0.69.0 => 0.69.5 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.70.3 is now available (your project is running on v0.69.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.70.3.
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.69.5.
info To upgrade, run "react-native upgrade".

Description

Package attribute in manifest file is deprecated on Android Gradle Plugin v7.3+. RN CLI has some kind of a bug that requires that the first folder (sorted alphabetically) in the project which has AndroidManifest.xml file, to have the package attribute. Otherwise, it will throw an error [1]:
error Failed to build the app: No package name found. Found errors in /REDACTED/src/main/AndroidManifest.xml

Error logs:

...
2022-10-20T17:12:53.571-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Apply script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' to settings 'android'' started
2022-10-20T17:12:53.574-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.574-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.574-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.575-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.575-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.575-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Compile script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (CLASSPATH)' started
2022-10-20T17:12:53.575-0300 [INFO] [org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler] Compiling script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' using SubsetScriptTransformer.
2022-10-20T17:12:53.665-0300 [DEBUG] [org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler] Timing: Writing script to cache at REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4/cp_dsl took: 0.089 secs
2022-10-20T17:12:53.665-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Compile script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (CLASSPATH)'
2022-10-20T17:12:53.665-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Compile script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (CLASSPATH)' completed
2022-10-20T17:12:53.665-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.666-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.666-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.668-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/3my38qsmuh2ufpxn0lk60zew4).
2022-10-20T17:12:53.669-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.669-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.669-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.669-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.669-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.669-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Compile script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (BODY)' started
2022-10-20T17:12:53.669-0300 [INFO] [org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler] Compiling script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' using BuildScriptTransformer.
2022-10-20T17:12:53.718-0300 [DEBUG] [org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler] Timing: Writing script to cache at REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n/dsl took: 0.048 secs
2022-10-20T17:12:53.718-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Compile script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (BODY)'
2022-10-20T17:12:53.718-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Compile script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (BODY)' completed
2022-10-20T17:12:53.719-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.723-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.723-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:12:53.732-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on instrumented jar cache.
2022-10-20T17:12:53.732-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on instrumented jar cache.
2022-10-20T17:12:53.747-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on instrumented jar cache.
2022-10-20T17:12:53.748-0300 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on dsl generic class cache for script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' (REDACTED/.gradle/caches/7.4/scripts/2duu92vbuvbgu3u6el23l0t5n).
2022-10-20T17:13:00.419-0300 [ERROR] [org.gradle.api.Script] :ReactNative:Unexpected empty result of running '[node, /REDACTED/node_modules/@react-native-community/cli/build/bin.js, config, --verbose]' command.
2022-10-20T17:13:00.420-0300 [ERROR] [org.gradle.api.Script] :ReactNative:Running '[node, /REDACTED/node_modules/@react-native-community/cli/build/bin.js, config, --verbose]' command failed.
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Apply script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' to settings 'android''
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Apply script '../node_modules/@react-native-community/cli-platform-android/native_modules.gradle' to settings 'android'' completed
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Apply settings file 'settings.gradle' to settings 'android''
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Apply settings file 'settings.gradle' to settings 'android'' completed
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Evaluate settings'
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Evaluate settings' completed
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Load build'
2022-10-20T17:13:00.420-0300 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Load build' completed
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Where:
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Script '/REDACTED/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 213
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred evaluating script.
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > error Failed to build the app: No package name found. Found errors in /REDACTED/src/main/AndroidManifest.xml
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --stacktrace option to get the stack trace.
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights.
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
2022-10-20T17:13:00.421-0300 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 7s

Reproducible Demo

  • Upgrade AGP to v7.3+
  • Remove package attribute from first alphabetically sorted folder containing AndroidManifest.xml
  • Add namespace declaration on that module's build.gradle
@cortinico
Copy link
Member

@thymikee this is sort of critical as it's needed for the CLI version that lands on 0.71 (which contains AGP 7.3)

@thymikee
Copy link
Member

@adamTrz can you prioritize that? Looks like we need to update the getPackageName

export function getPackageName(manifestPath: string) {
const androidManifest = fs.readFileSync(manifestPath, 'utf8');
let packageNameMatchArray = androidManifest.match(/package="(.+?)"/);
to support the namespace from build.gradle. Since package is now deprecated, let's treat it as a fallback solution and use namespace first

@cortinico
Copy link
Member

@thymikee @adamTrz I've took a stance at this as this was blocking me on RN's end.

Can you folks review and merge this on?
#1727

@adamTrz
Copy link
Collaborator

adamTrz commented Oct 27, 2022

@thymikee @adamTrz I've took a stance at this as this was blocking me on RN's end.

Can you folks review and merge this on? #1727

Already approved. Thanks for jumping in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants