FirebaseInstanceId is Deprecated

Hi

During an ugrade I received this error message.

“FirebaseInstanceId is Deprecated: The FirebaseInstanceId class has been deprecated and replaced by FirebaseMessaging.getInstance().getToken(). It’s highly probable that a library you’re using (like Backendless) or your own code is still trying to use the old, now removed, FirebaseInstanceId.”

I found the same problem but not very clear how to solve it.

Thanks, Mario

Hi Mario,

What version of the Backendless SDK do you use?

Regards,
Mark

// Backendless
implementation group: ‘com.backendless’, name: ‘backendless’, version: ‘6.3.6’

I’m working in a Demo SMS App to check just the problem and finally arrive to the same error following the Documentation of the website.

 private fun proceedWithDeviceRegistration(context: Context) {
        Log.d("FirstFragment", "Procediendo con el registro del dispositivo.")
        val channels = ArrayList<String>()
        channels.add("default") // O el canal que desees

        // La siguiente línea asume que Backendless.initApp() ya se ejecutó
        Backendless.Messaging.registerDevice(channels, object : AsyncCallback<DeviceRegistrationResult> { // Changed here
            override fun handleResponse(response: DeviceRegistrationResult?) { // Changed here
                Log.i("FirstFragment", "Dispositivo registrado con Backendless. Device ID: ${response.toString()}")
                Toast.makeText(context, "Dispositivo registrado para notificaciones!", Toast.LENGTH_LONG).show()
            }

            override fun handleFault(fault: BackendlessFault?) {
                Log.e("FirstFragment", "Error registrando dispositivo: ${fault?.message}")
                Toast.makeText(context, "Error registrando dispositivo: ${fault?.message}", Toast.LENGTH_LONG).show()
            }
        })
    }

Please try upgrading to the following version:

https://mvnrepository.com/artifact/com.backendless/java-sdk-common/7.0.9

Screenshot 2025-07-24 at 20.12.08

// Backendless
implementation(group = “com.backendless”, name = “backendless”, version = “7.0.9”)

Maybe must be different coding?

Screenshot 2025-07-24 at 20.17.52

Typing 6.3.6 no error but 7.0.9 give me the error just try to compile.

Make sure the dependency is specified exactly as shown on the page I referenced:

OK copy & paste offer me this code

implementation(“com.backendless:java-sdk-common:7.0.9”)

and now …

I am sorry, I don’t quite understand where you copy/paste it to. Have you thought about taking your configuration file and posting it to chatgpt?

The versions 6.7.5 or 7.0.9 even 8.0.0-RC1 not working because not found.

Back to the only version working is 5.2.0 but to old for the Google Message.

Ask ChatGPT and also Grok without a solution.
Thanks, Mario

Hi @Mario_Ghersi ,

As Mark pointed out you use an old Backendless SDK wich is deprecated now.
Instead you should use our new Android SDK which has different signature and rely on newer dependencies.

Please replace line from your screen shoot by implementation("com.backendless:android-client-sdk:7.0.9") and try to rebuild your project.

Regards, Andriy

Dear Andriy

OK this help me to find the right version and now can you send me information of the new code because still give me errors.

Log.d("FirstFragment", "Procediendo con el registro del dispositivo.")
    val channels = ArrayList<String>()
    channels.add("default")

    if (Backendless.getApplicationId() != null) {
        Backendless.Messaging.registerDevice(channels, object : AsyncCallback<DeviceRegistrationResult> {
            override fun handleResponse(response: DeviceRegistrationResult?) {
                Log.i("FirstFragment", "Dispositivo registrado con Backendless. Device ID: ${response?.toString() ?: "null"}")
                if (!isDetached && !context.isFinishing && context !is Activity && !context.isDestroyed) {
                    Toast.makeText(context, "Dispositivo registrado para notificaciones!", Toast.LENGTH_LONG).show()
                }
            }

            override fun handleFault(fault: BackendlessFault?) {
                Log.e("FirstFragment", "Error registrando dispositivo: ${fault?.message}")
                if (!isDetached && !context.isFinishing && context !is Activity && !context.isDestroyed) {
                    Toast.makeText(context, "Error registrando dispositivo: ${fault?.message}", Toast.LENGTH_LONG).show()
                }
            }
        })
    } else {
        Log.e("FirstFragment", "Backendless no inicializado. Llama a Backendless.initApp() primero.")
    }
}

This code is not working, these are the errors:

Thanks, Mario

@Mario_Ghersi ,

Just checked your case.
Beside Android SDK itself you also need to add next dependencies to your application:

implementation("com.backendless:java-sdk-common:7.0.9")
implementation("com.backendless:android-client-sdk:7.0.9")

In the new version of Backendless SDK there were some minor changes so you will need to adapt code in some places. For example, to access application ID with which your app was initialized you need to make next call Backendless.getApplicationIdOrDomain() instead of Backendless.getApplicationId().

Regards, Andriy

Hi Andriy

I’m following the documentation:

but is not the last version still give me errors and don’t know how to write the code.
Also ask Grok.com but no info of the new implementation.
Can you give me the code because all the Android Apps must be working by the end of the next month under the new code.

Thanks, Mario

Hi @Mario_Ghersi

We need more information from you about the current situation.
What specific errors are you encountering now?
Have you added the dependencies Andriy mentioned?

implementation("com.backendless:java-sdk-common:7.0.9")
implementation("com.backendless:android-client-sdk:7.0.9")

You may also need to add the following dependency in addition to those two:

implementation("com.backendless:java-client-sdk:7.0.9")

Please clarify what code you’re currently trying to run and what errors you’re getting.
Were you able to run the minimal example from the documentation and successfully register the device?

Regards,
Viktor

Dear Viktor

No, I can’t run the minimal android software, waste another day going in circles.

My Test minimal app is:

package com.isolutions.smsapp

object Default {
const val APPLICATION_ID = “C4BBAE0D-39FF-433D-AED7-5740B4A6E863”
const val API_KEY = “267EC2CE-8BF5-4DB7-A0CD-639F2721FABC”
const val SERVER_URL = “https://api.backendless.com
const val MY_APP_ID = “com.isolutions.smsapp”
}

And the json file is:

{
“project_info”: {
“project_number”: “1054150656926”,
“project_id”: “smsapp-62ad7”,
“storage_bucket”: “smsapp-62ad7.firebasestorage.app”
},
“client”: [
{
“client_info”: {
“mobilesdk_app_id”: “1:1054150656926:android:c33b2530ee04f512b74c8f”,
“android_client_info”: {
“package_name”: “com.isolutions.smsapp”
}
},
“oauth_client”: ,
“api_key”: [
{
“current_key”: “AIzaSyB2z4fGzD0HKDbQXOKhzwCzdpiYxahXz5Q”
}
],
“services”: {
“appinvite_service”: {
“other_platform_oauth_client”:
}
}
}
],
“configuration_version”: “1”
}

Maybe you can make a quick sample code to run this:

private void initNotification() {
Log.i(“LoginResult”, “initNotification INIT”);
List channels = new ArrayList<>();
channels.add(“default”);

    // Verificar permisos antes de registrar
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
            if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
                Log.d("FirstFragment", "Mostrando justificación para permiso.");
            } else {
                Log.d("FirstFragment", "Solicitando permiso.");
            }
            requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
            return;
        }
    }

    Log.i("LoginResult", "Verificó Permisos");

    if (Backendless.getApplicationIdOrDomain() != null) {
        Log.i("LoginResult", "getApplicationIdOrDomain");
        Backendless.Messaging.registerDevice(channels, new AsyncCallback<DeviceRegistrationResult>() {
            @Override
            public void handleResponse(DeviceRegistrationResult response) {
                Log.i("LoginResult", "initNotification response: " + (response != null ? response.toString() : "null"));
                if (response != null) {
                    // Aquí puedes llamar a readDeviceId() si lo necesitas
                } else {
                    Log.w("LoginResult", "Response is null");
                }
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                Log.e("LoginResult", "initNotification response error: " + fault.toString());
                Toast.makeText(requireContext(), "Error al registrar dispositivo: " + fault.getMessage(), Toast.LENGTH_SHORT).show();
            }
        });
    } else {
        Log.e("FirstFragment", "Backendless no inicializado. Llama a Backendless.initApp() primero.");
    }
}

Thanks, Mario

Hello @Mario_Ghersi

Consider, for example, the message:

Unresolved reference 'isFinishing'. :98

we see context.isFinishing - but in your example you don’t see the context variable being retrieved/initialized. Is your context variable Context or Activity or something else? In such a situation it is impossible to say why you have this error.

I copied this code to my project, so far I see only two errors:

  1. with the requireContext() method - it is not clear whether you are using this method inside the Fragment, most likely so, then there should be no problems, or are you using it from the androidx.core.content package?
  2. with the requestPermissionLauncher variable - in your example it is not visible where this change is declared.
    Please tell me what problems you have with the code you provided?

Regards,
Volodymyr

Hi Volodymyr

The full function is:

private void initNotification() {
    Log.i("LoginResult", "initNotification INIT");
    List<String> channels = new ArrayList<>();
    channels.add("default");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
            if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
                Log.d("FirstFragment", "Mostrando justificación para permiso.");
            } else {
                Log.d("FirstFragment", "Solicitando permiso.");
            }
            requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
            return;
        }
    }

    Log.i("LoginResult", "Verificó Permisos");

    if (Backendless.getApplicationIdOrDomain() != null) {
        Log.i("LoginResult", "getApplicationIdOrDomain");
        Backendless.Messaging.registerDevice(channels, new AsyncCallback<DeviceRegistrationResult>() {
            @Override
            public void handleResponse(DeviceRegistrationResult response) {
                Log.i("LoginResult", "initNotification response: " + (response != null ? response.toString() : "null"));
                if (response != null) {
                    // Aquí puedes llamar a readDeviceId() si lo necesitas
                } else {
                    Log.w("LoginResult", "Response is null");
                }
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                Log.e("LoginResult", "initNotification response error: " + fault.toString());
                Toast.makeText(requireContext(), "Error al registrar dispositivo: " + fault.getMessage(), Toast.LENGTH_SHORT).show();
            }
        });
    } else {
        Log.e("FirstFragment", "Backendless no inicializado. Llama a Backendless.initApp() primero.");
    }
}

Please provide the right code to register the device to a default channel.
Thanks, Mario

Hi

@Volodymyr_Ialovyi or @Viktor_Mudrevsky or @Andriy_Konoz please I’m still waiting the code to register a “default” channel to handle notifications, for the new version 7.0.9

Thanks, Mario

Hi @Mario_Ghersi

I’ve uploaded a file named Mario.zip to your SMSApp application. You can find it in the root directory of File Service.

The archive contains a minimal project that registers a device. I tested it in my Android Studio, and it worked — the device was registered successfully, and a corresponding record appeared in the DeviceRegistration table.

I hope this minimal project helps you.

Regards,
Viktor

Hi Viktor

18 days later finally your code is working, a lot of upgrades and tests. I will write here for my self some of the setups to check.

plugins {
id ‘com.android.application’ version ‘8.11.1’ apply false
id ‘com.google.gms.google-services’ version ‘4.4.3’ apply false
}

and

plugins {
id ‘com.android.application’
id ‘com.google.gms.google-services’
}

android {
namespace ‘com.isolutions.smsapp’
compileSdk 36

defaultConfig {
    applicationId "com.isolutions.smsapp"
    minSdk 28
    targetSdk 36
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_21
    targetCompatibility JavaVersion.VERSION_21
}

}

dependencies {
implementation ‘androidx.core:core-ktx:1.17.0’
implementation ‘androidx.appcompat:appcompat:1.7.1’
implementation ‘com.google.android.material:material:1.12.0’
testImplementation ‘junit:junit:4.13.2’
androidTestImplementation ‘androidx.test.ext:junit:1.3.0’
androidTestImplementation ‘androidx.test.espresso:espresso-core:3.7.0’

implementation platform('com.google.firebase:firebase-bom:34.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.firebase:firebase-messaging:25.0.0'
implementation group: 'com.backendless', name: 'android-client-sdk', version: '7.0.9'
implementation group: 'io.socket', name: 'socket.io-client', version: '2.1.2'

}

The Java Version was one of the problems to upgrade correctly to 21.

Now it’s time to implement in my code.
Thanks, Mario