-
Notifications
You must be signed in to change notification settings - Fork 251
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
When adding amplify_push_notifications_pinpoint
dependency, the Android build fails
#5739
Comments
Hello @ramon-san, thank you for taking the time to raise this issue. Are you using Gen 1, or setting up push notifications on a Gen 2 app? I don't seem to be able to reproduce this particular error on my end with a Gen 1 app, and using the push notifications library isn't directly supported for Gen 2 (generally you may look at using AWS SNS to set up a pubsub model for push notifications). |
Answering your questionsThanks for the response @ekjotmultani! I am a bit confused as in the question regarding if my app is Gen 1 or Gen 2. I try to follow the Gen 2 docs as much as possible, but there are features from Gen 1 that are not documented in Gen 2. The libraries are also the same between Gen 1 and Gen 2, so if you let me know how to differentiate between these two generations I can inform you. As of my current understanding I would say I use both Gen 1 and Gen 2. I am sure I followed the Gen 2 documentation for:
Where I followed the Gen 1 documentation is in:
Here is a copy of my // Configs
import 'package:pey/configs/constants.dart';
const amplifyConfig = {
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"analytics": {
"plugins": {
"awsPinpointAnalyticsPlugin": {
"pinpointAnalytics": {
"appId": EnvironmentVars.pinpointAppId,
"region": EnvironmentVars.awsRegion
},
"pinpointTargeting": {"region": EnvironmentVars.awsRegion}
}
}
},
"notifications": {
"plugins": {
"awsPinpointPushNotificationsPlugin": {
"appId": EnvironmentVars.pinpointAppId,
"region": EnvironmentVars.awsRegion
}
}
},
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"IdentityManager": {"Default": {}},
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": EnvironmentVars.cognitoIdentityPoolId,
"Region": EnvironmentVars.awsRegion
}
}
},
"CognitoUserPool": {
"Default": {
"PoolId": EnvironmentVars.cognitoUserPoolId,
"AppClientId": EnvironmentVars.cognitoUserPoolAppClientId,
"Region": EnvironmentVars.awsRegion
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH",
"socialProviders": ["GOOGLE", "APPLE"],
"usernameAttributes": ["EMAIL"],
"signupAttributes": [],
"passwordProtectionSettings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"OAuth": {
"WebDomain": EnvironmentVars.cognitoDomain,
"AppClientId": EnvironmentVars.cognitoUserPoolAppClientId,
"SignInRedirectURI": "pey://",
"SignOutRedirectURI": "pey://",
"Scopes": [
"email",
"openid",
"phone",
"aws.cognito.signin.user.admin"
],
}
}
},
"PinpointAnalytics": {
"Default": {
"AppId": EnvironmentVars.pinpointAppId,
"Region": EnvironmentVars.awsRegion
}
},
"PinpointTargeting": {
"Default": {"Region": EnvironmentVars.awsRegion}
}
}
}
},
"api": {
"plugins": {
"awsAPIPlugin": {
"ApiGraphQL": {
"endpointType": "GraphQL",
"endpoint": EnvironmentVars.appSyncEndpoint,
"region": EnvironmentVars.awsRegion,
"authorizationType": "AMAZON_COGNITO_USER_POOLS"
},
"ApiREST": {
"endpointType": "REST",
"endpoint": EnvironmentVars.apiGatewayEndpoint,
"region": EnvironmentVars.awsRegion,
"authorizationType": "NONE"
}
}
}
}
}; As you can see I don't use the CLI to configure Amplify in my project, I build my backend independently using CDK and then import existing resources into my project based on the environment I am using. I also copy the function I use to configure my Amplify resources in the Future<void> configureAmplify() async {
try {
if (Amplify.isConfigured) {
safePrint("Amplify is already configured 🎉");
return;
}
await Amplify.addPlugins([
AmplifyAnalyticsPinpoint(),
AmplifyAuthCognito(),
AmplifyPushNotificationsPinpoint(),
AmplifyAPI(),
]);
await Amplify.configure(jsonEncode(amplifyConfig));
safePrint("Successfully configured Amplify 🎉");
} on Exception catch (e) {
safePrint('An error occurred configuring Amplify: $e');
rethrow;
}
} Solving the issueRight now I just plugged the GitHub issue into Claude and it helped me solve the issue with simple changes to my Gradle configuration files. I copy the changes that solved my issue:
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
plugins {
id "com.android.application"
id "kotlin-android"
id "kotlinx-serialization"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
} I am not a big fan of this solution because it seems like the Amplify library should simply work with the default Flutter configurations set on Gradle, but for now this solved the issue and the app is able to run. FeedbackThe documentation that exists for integrating notification on Android (this and this) is very confusing and not high quality. I want to integrate this without having to connect with the Firebase CLI (no need for the whole Firebase integration if I only want notifications to work), but the docs are not a good guide for doing so. The aforementioned docs do a great job explaining how to integrate notifications on iOS, but not so for Android. As I previously mentioned, push notifications work well on iOS which means the configuration is working, but causes some problems with Android. I still need to connect my Firebase resources in order to set up Android notifications, but the docs are so painful to follow that I decided to ship some other features before I got back to this. Will work on it tonight and let you know when I have Android notifications working as well. |
Hi @ramon-san, thank you very much for providing these details, given the config file I can see that you are using the package from Gen 1 in a Gen 2 app. I suspect this is why this issue with the Thank you for the feedback on our documentation as well, it is good to know that it is confusing going back and forth on two pages to set up the push notifications. This feedback will allow us to improve our documentation going forward, so thanks again! As for using Amplify push notifications without Firebase integration, it is unfortunately a requirement of the implementation that a Firebase Cloud Messaging key is needed for notifications to work on Android. You should not have to use the Firebase CLI however, having the json file from the Firebase console should be enough. Please let me know if you have any questions or other issues when you get to working on Android notifications in your application, otherwise since the initial issue has a resolution I will be closing out this issue. Thank you again for the thought and care you provide in your responses and issue descriptions. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Thanks for the help and clarifications @ekjotmultani! Just finished integrating notifications for Android and it works just fine. As you point out, I didn't have to use any Firebase CLI. Just added |
Description
I am adding notifications to an app I'm building, but have trouble when implementing this for Android. I already did all the setup for iOS and it works just fine, but Android is causing trouble. By simply adding this line to my
pubspec.yaml
I get an error:When I run the
flutter run
command I get the following error:When I run this same command on verbose (
flutter run --verbose
) I get the following output regarding this problem:I already tried rebuilding the project after using
flutter clean
and./gradlew clean
, but the error persists. Also tried building from a clean copy of the repository and the error continues. I also ran theflutter doctor -v
command and everything is okay with Flutter:Not sure what would be the most appropriate fix or if this is a known issue, my current gradle config files are the following:
This all worked just fine with all the other Amplify imports that I use, but caused problems with
amplify_push_notifications_pinpoint
. My completepubspec.yaml
is this:Categories
Steps to Reproduce
Create an amplify project using the configs mentioned in the description, then try adding the
amplify_push_notifications_pinpoint
library and executingflutter run
for Android.Screenshots
No response
Platforms
Flutter Version
3.24.3
Amplify Flutter Version
^2.0.0
Deployment Method
AWS CDK
Schema
No response
The text was updated successfully, but these errors were encountered: