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

amazon-cognito-identity-js: missing namespace information required by Gradle 8 #12306

Closed
3 tasks done
adolfogc opened this issue Oct 15, 2023 · 11 comments · Fixed by #12371
Closed
3 tasks done

amazon-cognito-identity-js: missing namespace information required by Gradle 8 #12306

adolfogc opened this issue Oct 15, 2023 · 11 comments · Fixed by #12371
Assignees
Labels
amazon-cognito-identity-js Used for issues related to this specific package within the monorepo Auth Related to Auth components/category bug Something isn't working dependencies Pull requests that update a dependency file React Native React Native related issue

Comments

@adolfogc
Copy link

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

"dependencies": {
    "@aws-amplify/auth": "^5.6.5",
    "@aws-amplify/core": "^5.8.5",
    "@react-native-masked-view/masked-view": "^0.3.0",
    "@react-navigation/native": "^6.0.16",
    "@react-navigation/stack": "^6.0.11",
    "@rescript/react": "^0.11.0",
    "@sentry/react-native": "^5.11.1",
    "amazon-cognito-identity-js": "^6.3.6",
    "jsc-android": "^250231.0.0",
    "react": "18.2.0",
    "react-native": "0.72.6",
    "react-native-gesture-handler": "^2.13.2",
    "react-native-gradle-plugin": "^0.71.19",
    "react-native-safe-area-context": "^4.7.2",
    "react-native-screens": "^3.25.0",
    "rescript-react-native": "^0.72.0",
    "rescript-react-navigation": "^6.0.3"
  },
  "devDependencies": {
    "@babel/core": "^7.23.2",
    "@babel/preset-env": "^7.23.2",
    "@babel/runtime": "^7.23.2",
    "@react-native-community/cli-platform-android": "^11.3.9",
    "@react-native-community/cli-platform-ios": "^11.3.9",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/gradle-plugin": "^0.74.0",
    "@react-native/metro-config": "^0.72.11",
    "@rnx-kit/align-deps": "^2.2.5",
    "@rnx-kit/babel-preset-metro-react-native": "^1.1.5",
    "@rnx-kit/cli": "^0.16.17",
    "@rnx-kit/metro-config": "^1.3.9",
    "@rnx-kit/metro-plugin-cyclic-dependencies-detector": "^1.1.2",
    "@rnx-kit/metro-plugin-duplicates-checker": "^2.1.2",
    "@rnx-kit/metro-resolver-symlinks": "^0.1.33",
    "@rnx-kit/metro-serializer": "^1.0.12",
    "@rnx-kit/tools-react-native": "^1.3.3",
    "@tsconfig/react-native": "^3.0.2",
    "@types/react": "^18.2.28",
    "@types/react-test-renderer": "^18.0.3",
    "babel-jest": "^29.7.0",
    "eslint": "^8.51.0",
    "jest": "^29.7.0",
    "metro-react-native-babel-preset": "0.76.8",
    "prettier": "^2.8.8",
    "react-native-dotenv": "^3.4.9",
    "react-test-renderer": "18.2.0",
    "rescript": "^10.1.4",
    "typescript": "4.8.4"
  },

Describe the bug

Building the Android version of a RN application fails when using Gradle 8 due to missing namespace information.

The error can be fixed by adding the following to build.gradle:

// ...
android {
  // ...
  namespace "com.amazonaws"
  // ...
}
// ...

Expected behavior

The package should work when using Gradle 8.

Reproduction steps

  1. Setup project using RN 0.72.6+
  2. Add amazon-cognito-identity-js as dependency
  3. Build Android version of the project

Code Snippet

// Not applicable.

Log output

A problem occurred configuring project ':amazon-cognito-identity-js'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
     
     If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@adolfogc adolfogc added the pending-triage Issue is pending triage label Oct 15, 2023
@chrisbonifacio chrisbonifacio added Auth Related to Auth components/category amazon-cognito-identity-js Used for issues related to this specific package within the monorepo React Native React Native related issue labels Oct 16, 2023
@cwomack cwomack self-assigned this Oct 16, 2023
@cwomack cwomack added investigating This issue is being investigated bug Something isn't working dependencies Pull requests that update a dependency file and removed pending-triage Issue is pending triage investigating This issue is being investigated labels Oct 16, 2023
@cwomack
Copy link
Member

cwomack commented Oct 17, 2023

Hello, @adolfogc 👋. I've been able to reproduce the issue on my side and will review this with the team internally for next steps. Going to mark this as a bug and update this issue on progress as it's made! It look like Gradle 8 introduced a breaking change and we are going to work on adopting it/resolving it to fix the build issues tied to the namespace errors.

Just to confirm for other that find this until the fix is implemented, did the changes you made to your build.gradle file completely resolves the issue for you?

@adolfogc
Copy link
Author

Hi @cwomack, thank you for your reply! Yes, just adding that line to the build.gradle fixed the error and allowed me to build the project.

@HuiSF
Copy link
Member

HuiSF commented Oct 18, 2023

Hi @adolfogc could you do my a favor, could you run the following command in your <project>/android directory and paste the output?

./gradlew --version

@adolfogc
Copy link
Author

Hi @HuiSF, this is the output:

------------------------------------------------------------
Gradle 8.0.1
------------------------------------------------------------

Build time:   2023-02-17 20:09:48 UTC
Revision:     68959bf76cef4d28c678f2e2085ee84e8647b77a

Kotlin:       1.8.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.8.1 (Eclipse Adoptium 17.0.8.1+1)
OS:           Mac OS X 14.0 aarch64

@adolfogc
Copy link
Author

Hi @HuiSF , @cwomack, this issue also affects other aws-amplify packages, such as @aws-amplify/pushnotification and @aws-amplify/rtn-push-notification, as well as some dependency packages like react-native-get-random-values. I will close the PR I submitted because the solution should probably fix the issue for all the aws-amplify packages at once.

@adolfogc
Copy link
Author

Just for reference, how they are tackling this issue in react-native-get-random-values: LinusU/react-native-get-random-values#48

@HuiSF
Copy link
Member

HuiSF commented Oct 19, 2023

Do you still have the logs of the build failure? @adolfogc

@HuiSF
Copy link
Member

HuiSF commented Oct 23, 2023

Didn't mean to close this issue with merging the PR. Reopen until the fix gets released.

@HuiSF HuiSF reopened this Oct 23, 2023
@adolfogc
Copy link
Author

Hi @HuiSF thank you for the fix, I looked at the PR (#12371) and wanted to bring to your attention that it seems like the pushnotification package was left behind (https://github.com/aws-amplify/amplify-js/blob/main/packages/pushnotification/android/src/main/AndroidManifest.xml)

@HuiSF
Copy link
Member

HuiSF commented Oct 26, 2023

Hi @adolfogc thanks for the callout! I think this legacy push notification package is being deprecated.

@nadetastic
Copy link
Member

The fix for this has been released and is available 6.0.5 as welll as 5.3.12 . I'll go ahead and mark this issue as closed, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amazon-cognito-identity-js Used for issues related to this specific package within the monorepo Auth Related to Auth components/category bug Something isn't working dependencies Pull requests that update a dependency file React Native React Native related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants