Help - Amplify Quick start example for Android
Environment information
Hello,
Trying to use AWS Amplify example for Android and followed the steps provided in https://docs.amplify.aws/android/start/quickstart/
Facing an error in "step 10 - Test in app":
* Command executed is - npx @aws-amplify/backend-cli generate graphql-client-code --format modelgen --model-target java --out app/src/main/java --app-id <your-amplify-app-id> --branch main
Replaced <your-amplify-app-id> with App ID
* Error observed - "InvalidCommandError: The Amplify Gen 2 CLI has been renamed to ampx
Resolution: Rerun using the ampx command name: "
Describe the bug
-
Using Android Studio, followed the steps in https://docs.amplify.aws/android/start/quickstart/ Android studio used: Android Studio Koala | 2024.1.1 Build #AI-241.15989.150.2411.11948838, built on June 11, 2024 Runtime version: 17.0.10+0-17.0.10b1087.21-11609105 amd64
-
During step 10 an error observed- ""InvalidCommandError: The Amplify Gen 2 CLI has been renamed to ampx Resolution: Rerun using the ampx command name: "
Reproduction steps
-
Choose Android Framework and follow the steps per the Quick start guide available here - https://docs.amplify.aws/android/start/quickstart/
-
All works well till step 7 ... I can see the Auth screen and the logins work as expected. Moved till step 10 and there is an error while executing the - "InvalidCommandError: The Amplify Gen 2 CLI has been renamed to ampx Resolution: Rerun using the ampx command name: "
-
Command executed is - npx @aws-amplify/backend-cli generate graphql-client-code --format modelgen --model-target java --out app/src/main/java --app-id
--branch main
FYI - Replaced
@ShanmugaCA thank you for reporting this. You should be able to generate the client code using the following command.
npx ampx generate graphql-client-code --format modelgen --model-target java --out app/src/main/java --app-id <app-id> --branch main
Transferring the issue to the documentation repository to update the android quickstart guide
note on the fix: we could update the command to following
npx --package @aws-amplify/backend-cli ampx
I'm a little confused by this one. I tried to replicate the issue and the command in the documentation works for me. The suggested command from @ykethan does not work.
This guide is generating models and downloading amplify_outputs.json outside of a gen2 project. The command itself is meant to be run within the Android project, not the backend project. Is it possible the command was being run in the wrong spot? I don't believe ampx is appropriate in this case, because the command is not being run in a gen2 project.
I was able to replicate the original error. I believe the command was run within the amplify backend project, and not within the Android project directory.
Per the instructions of the documentation:
Now, let's go back to your Android application and test out the user isolation of the to-do items. Fetch the latest amplify_outputs.json and model files by re-running the following command in your Android Studio terminal.
This command should be run within the app's project directly. You can't run an ampx command within a directory that doesn't have an amplify gen2 project.
I'm going to go ahead and close this issue, but if there is anything I have misunderstood, please re-open.