Android Studio App is running but unable to go register

Mission: PUSH COMMANDER
Task: Register device for push notifications

Please, describe your problem here.

All good in MainActivity.java:

The virtual device is showing error “App keeps stopping”.

on Main Activity showing unused resources
import com.backendless.DeviceRegistration;
import com.backendless.commons.ApiKey;
import com.backendless.android.gms.common.api.Api;

image

image

Any suggestions please. Thanks

Hi @Alejandro_Tamonan,

At first sight, the problem seems to be with the project, as it throws an error:

The virtual device is showing the error “App keeps stopping”.

Please provide us with your project with all sensitive data removed from it. So we can check it and reproduce the issue on our side.

Best,
Marina

Hi Marina,

Uploaded my project here.

The basic difference is that in the build.gradle: As jcenter has been discontinued, replaced it with mavencentral which eventually commented out in the App in my endeavour at trial and error to make my project work.

Looking forward to your feedback. Thanks in advance.
PushCommanderApp.zip (28.3 MB)

Hi @Alejandro_Tamonan,

We have studied your project and found it is missing the necessary configuration files. We were unable to reproduce the problem in our project. Please read the documentation below. We suggest you follow the instructions provided there. To deliver a push notification to Android, your app must be configured to use Firebase Cloud Messaging the Backendless backend must be configured with a Google API Key.

Push Notification Setup (Android) - Backendless SDK for Android/Java API Documentation

If you have any further questions, feel free to text us.

Regards,
Marina

Hi Marina,

Please see below snippet of my app logcat. The virtual device is not showing any error, and App is not stopping as it did before. Any suggestions?

Thanks

Hi @Alejandro_Tamonan

The answer to your question is likely to be found on the Firebase side.

Regarding the mission as a whole, I attempted to reproduce and I was able to successfully register the device. Here’s what I did:

  • carefully followed the instructions.
  • obtained the google-services.json file.
  • added it to my project in the ‘app’ folder.
  • added the key in the console.
  • included all necessary dependencies.

I see that you’ve also received the key and your project’s code appears to be correct. Additionally, please ensure that you log in to Firebase from your Android Studio if you haven’t already.
Afterward, try running the code again. I hope this registration issue will be resolved.

Regards,
Viktor

Hi guys,

I’ve followed everything and my App is working, even getting the error messages (App Error Handling). The error is probably not from this end, kindly check. Please see attached snapshot of virtual device and logcat.

“Status Code: 200” (Is the issue in Firebase end?

Hello @Alejandro_Tamonan

Changed in build.gradle.kts (:app):

implementation("com.backendless","backendless","5.7.1" )

to

implementation("com.backendless", "android-client-sdk", "7.0.7")

(latest version java-sdk)
and in com.myapp.pushcommanderapp.MainActivity:

Backendless.initApp(this, <actualAppId>, <wrongAndroidApiKey>);

to

Backendless.initApp(this, <actualAppId>, <actualAndroidApiKey>);

and run your ‘app’ → device registered and added (objectId: E125860B-9B61-4541-BF79-134E2BB1FCE1, deviceId: 56121ee9863d7f8a, created: 11/01/2023 13:13:09) to DeviceRegistration table in your application with id 7707245F-06B5-64A7-FF6C-88505D473400.
So your project works after these two edits, make them and please let us know if it works for you.

About SERVICE_NOT_AVAILABLE:
This issue comes when your device is not able to communicate with FCM due to some reason. You can perform following checks to make it working:

  1. Check your internet connecting with device
  2. Switch between mobile data to wifi or vice versa
  3. Device date time should be correct.
  4. Try cleaning cache.
  5. Kill the application and start it again.

Also you can try to fix it:

  1. Clean project (Under Build tab)
  2. Rebuild project(Under Build tab)
  3. Recreate emulator (using AVD)

Let me clarify if I understood correctly: did you manage to solve the problem and register the device?

Regards,
Vladimir

Hello @Alejandro_Tamonan

I also want to draw your attention to the possibility Share secret data with Backendless team

Regards,
Vladimir

Hi guys,

I got a notice from Firebase Crashlytics that the issue is related to connection is Google Play Registration.

I had a really bad experience with previous learning to code… paid couple of hundreds over 1K USD in more than year to subscribe an app promising to me to be able to be able learn it easily…

Long story short, not enough support… I was able to find Backendless and (started free to avoid said bad experience) liked your ‘Mission’ thingy for learning so here I am. Will eventually metamorphose into a paying subscriber if I become sure that I will be able to finally build an application to use in my work.

Thank you thus far for the support, hoping to overcome all the walls in my learning curve.