Mission: PUSH COMMANDER
Task: Register device for push notifications
Have followed the video and checked and rechecked the “Push Notification Setup (Android)” (Flutter SDK) several times
4:45 in video, re AndroidManifest.xml line:
“com.backendless.push.BackendlessFCMService” appears in red, with error “Class referenced in the manifest, com.backendless.push.BackendlessFCMService, was not found in the project or the libraries”
App ‘build.gradle dependencies’ entry look correct to me:
implementation group: ‘com.backendless’, name: ‘backendless’, version: ‘6.3.3’
(6.3.3 is current version, have also tried video version: 5.7.0).
Earlier versions of Android Studio had a ‘synch gradle’ message when the gradle files changed, but don’t see that in this later version (4.1.3).
(keyword) ’service’ shows warning “Exported service does not require permission”
I have just created a clean project to register a device for push notifications.
Here are my steps for a successful setup:
Add google.services.json file to android/app.
Add proguard-rules.pro file to android/app with the following content:
-dontwarn com.backendless. **
-dontwarn weborb. **
-keep class weborb. ** {*;}
-keep class com.backendless. ** {*;}
Changes in app/build.gradle:
Add line: apply plugin: 'com.google.gms.google-services'
Set value: minSdkVersion 19
Change the content of buildTypes, to connect proguard:
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
minifyEnabled true
proguardFiles getDefaultProguardFile ('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
Nikita,
Printed instructions and marked them off going down the list. Most lines were already there; built the file‘proguard-rules.pro’ in Notepad, copied the text from your post into it, and put it into ‘android/app’ (is right under ‘google.services.json’).
Other differences:
minSdkVersion was at 21
implementation ‘com.google.firebase: firebase-iid’ is new
left the line from the original video: implementation group: ‘com.backendless’, name: ‘backendless’, version: ‘6.3.3’
New ‘service’ section addition to AndroidManifest.xml caused several new errors; seems .xml didn’t like the space after the ‘:’ (colon). Removed that and errors same as before:
‘com.backendless.backendless_sdk.common.FlutterBackendlessFCMService’ is still red, showing error “Class referenced in the manifest, com.backendless.backendless_sdk.common.FlutterBackendlessFCMService, was not found in the project or the libraries”
android:exported shows error “Unknown attribute android:exported”
I note the ‘service’ keyword shows warning(?) “Exported service does not require permission”; setting android:exported = “false”> removes that warning.
Perhaps a next step is to try to run the correct Flutter API call code for the “Register device for push notifications” task (BKNDLSS-27399); is that in the works somewhere?
Jim
Nikita,
Getting error ‘The method ‘showOverlayNotification’ isn’t defined’ on the ‘showOverlayNotification’ call. Where can I find it?
If I comment that call out, have a problem with the app/build.gradle dependency
implementation ‘com.google.firebase: firebase-iid’
Gives compile-time error:
Execution failed for task ‘:app:checkDebugAarMetadata’.
Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’.
Could not find com.google.firebase: firebase-iid:.
Required by: project :app
If I comment out that line out of ‘dependencies’, get runtime error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId;
The method showOverlayNotification is defined in overlay_support: ^1.2.1 package. But this is just my way of displaying notifications. You can use your own approach.
If you are using flutter you do not need to do: implementation group: ‘com.backendless’, name: ‘backendless’, version: ‘6.3.3’
All of this is included in the backendless_sdk: ^ 7.1.8 which you add in the dependencies in your pubspec.yaml file.
You may receive this error Could not find com.google.firebase: firebase-iid for 2 reasons:
You forgot to add the line: classpath 'com.google.gms:google-services:4.3.10'
in android/build.gradle file. Like this:
Nikita,
Once again your work led to the fix: for whatever reason the system was not able to resolve com.google.firebase: firebase-iid without an explicit version number. Eventually found the latest version (implementation “com.google.firebase:firebase-iid:21.1.0”) and that compiled.
The AndroidManifest.xml service element line
android:name = “com.backendless.backendless_sdk.common.FlutterBackendlessFCMService”
is still red and shows the error “Class referenced in the manifest, com.backendless.backendless_sdk.common.FlutterBackendlessFCMService, was not found in the project or the libraries”.
But … your ‘register device’ code ran successfully, completing this task!!
Another weird one … thanks again for all your help!
Jim
Not sure what will help, but if you open an android folder through Android Studio, and after build.gradle, then it will not be underlined in red.
But then you won’t be able to edit your dart files and you will only see the android folder.
Apparently, Android Studio is not doing so well with flutter and java code synchronization.
P.S. I was getting an error with explicit version of com.google.firebase:firebase-iid.
magic…