Ошибка fcm android

ошибка компиляции Android

ed_vendor_manifest.xml"
Error: The following instances are in the device manifest but not specified in framework compatibility matrix: 
    [email protected]::IFingerprintAuthenticator/default
    [email protected]::IFingerprintCalibration/default
    [email protected]::IFingerprintEngineering/default
    [email protected]::IFingerprintNavigation/default
    [email protected]::IFingerprintRecalibration/default
    [email protected]::IFingerprintSenseTouch/default
    [email protected]::IFingerprintSensorTest/default
    [email protected]::IDms/default
    [email protected]::ISwfingerprint/default
Suggested fix:
1. Check for any typos in device manifest or framework compatibility matrices with FCM version >= 2.
2. Add them to any framework compatibility matrix with FCM version >= 2 where applicable.
3. Add them to DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE or DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE.
10:39:53 ninja failed with: exit status 1

#### failed to build some targets (11:08 (mm:ss)) ####

1. Добавьте новые файлы в AP / device / qcom / msm8937_64 / manifest.xml

<hal format="hidl">
        <name>com.fingerprints.extension</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IFingerprintSensorTest</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintEngineering</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintAuthenticator</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintCalibration</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintNavigation</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintRecalibration</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintSenseTouch</name>
            <instance>default</instance>
        </interface>
    </hal>

2. Затем скомпилируйте

make vendorimage

Сообщить об ошибке

Анализ причин

(1) В сообщении об ошибке out / target / product / msm8937_64 / Verified_assembled_vendor_manifest.xml в этом файле нет com.fingerprints.extension, что указывает на отсутствие соответствующей конфигурации

(2) Поскольку матрица совместимости фреймворка FCM добавляется в AP / device / qcom / msm8937_64 / manifest.xml, это означает, что элемент конфигурации com.fingerprints.extension в файле verify_assembled_vendor_manifest.xml получен в результате анализа других файлов. Добавьте соответствующий FCM в AP / hardware / interfaces / compatibility_matrices / compatibility_matrix.3.xml, вам нужно добавить его в соответствующее место файла AP / hardware / interfaces / compatibility_matrices / compatibility_matrix.3.xml

 <name>com.fingerprints.extension</name>
        <version>1.0</version>
        <interface>
            <name>IFingerprintSensorTest</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintEngineering</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintAuthenticator</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintCalibration</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintNavigation</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintRecalibration</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IFingerprintSenseTouch</name>
            <instance>default</instance>
        </interface>
    </hal>
	<hal format="hidl">
        <name>vendor.sw.swfingerprint</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ISwfingerprint</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl" optional="false">

3. Снова скомпилируйте make vendorimage.

Asked
6 years, 8 months ago

Viewed
12k times

Firstly we create FCM project and get on googlePlayService.json file and if we send notification by using FCM console then Notification send successfully in our android app But if we send notification through local server then 401 unauthorized error comes so please suggest me can we change code in php server or android.

Brian Tompsett - 汤莱恩's user avatar

asked Sep 13, 2016 at 15:06

Sonu negi's user avatar

4

To get Firebase Cloud Messaging’s Server Key, please goto your Firebase Console and see the following screen shot to get your «Server Key» value.

enter image description here

answered Oct 24, 2016 at 7:12

hmaxf2's user avatar

hmaxf2hmaxf2

6565 silver badges10 bronze badges

Firebase Cloud Messaging (FCM) is a powerful messaging platform used to send push notifications to Android devices. However, sometimes developers may encounter the Firebase 401 Unauthorized Error, which can be caused by several factors. This error can cause the push notifications to fail and result in a poor user experience. In this article, we will explore several methods to fix this error and ensure successful push notifications.

Method 1: Update the Server Key

To fix the Firebase 401 unauthorized error FCM in Android, you can update the server key. Here are the steps to do it:

  1. Go to the Firebase Console and select your project.
  2. Click on the gear icon and select «Project settings».
  3. Click on the «Cloud Messaging» tab.
  4. Copy the «Server key» value.

Now, update the server key in your Android app. Here is an example code:

FirebaseOptions options = new FirebaseOptions.Builder()
        .setApplicationId("your_app_id")
        .setApiKey("your_api_key")
        .setDatabaseUrl("https://your-app.firebaseio.com")
        .setGcmSenderId("your_sender_id")
        .setProjectId("your_project_id")
        .build();

FirebaseApp.initializeApp(this, options);

String serverKey = "your_server_key";

FirebaseMessaging.getInstance().setAutoInitEnabled(true);
FirebaseMessaging.getInstance().getToken(serverKey, "FCM").addOnCompleteListener(new OnCompleteListener<String>() {
    @Override
    public void onComplete(@NonNull Task<String> task) {
        if (task.isSuccessful()) {
            String token = task.getResult();
            Log.d(TAG, "FCM token: " + token);
        } else {
            Log.e(TAG, "Failed to get FCM token", task.getException());
        }
    }
});

In the code above, replace the «your_server_key» value with the copied «Server key» value from the Firebase Console.

This should fix the Firebase 401 unauthorized error FCM in Android.

Method 2: Check for Incorrect Package Name or Sender ID

If you are facing Firebase 401 Unauthorized Error FCM, it is possible that you have an incorrect package name or sender ID. To fix this, you can check your package name and sender ID in your Firebase console and make sure they match the ones in your Android app.

Here is how you can do it step by step:

  1. Open your Firebase console and select your project.
  2. Go to your project settings by clicking on the gear icon in the top left corner.
  3. Scroll down to the «Your apps» section and select your Android app.
  4. Check the «Package name» and «SHA certificate fingerprints» fields in the «General» tab. Make sure they match the ones in your Android app. You can find your package name in your app’s build.gradle file and your SHA certificate fingerprints in your app’s signing report.
  5. Check the «Sender ID» field in the «Cloud Messaging» tab. Make sure it matches the one in your Android app. You can find your sender ID in your Firebase console or in your app’s FirebaseMessagingService class.

Here is an example code that shows how to check the package name and sender ID in your Android app:

// Get the package name
String packageName = getApplicationContext().getPackageName();

// Get the SHA certificate fingerprints
String sha1 = "";
try {
    PackageInfo info = getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        sha1 = Base64.encodeToString(md.digest(), Base64.NO_WRAP);
    }
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
    e.printStackTrace();
}

// Get the sender ID
String senderId = getString(R.string.gcm_defaultSenderId);

// Compare the package name and sender ID with the ones in your Firebase console
if (!packageName.equals("your_package_name") || !sha1.equals("your_sha_certificate_fingerprints") || !senderId.equals("your_sender_id")) {
    Log.d(TAG, "Incorrect package name or sender ID");
}

That’s it! By checking the package name and sender ID, you can fix the Firebase 401 Unauthorized Error FCM.

Method 3: Check for Invalid API Key

If you are facing the Firebase 401 unauthorized error FCM, it means that your app is not authorized to use Firebase Cloud Messaging (FCM) service. One of the reasons for this error is an invalid API key. In this tutorial, we will show you how to check for an invalid API key and fix the Firebase 401 unauthorized error FCM.

Step 1: Check for an invalid API key

To check for an invalid API key, you can use the FirebaseInstanceId.getInstance().getToken() method. This method returns the current token for the app instance. If the token is null or empty, it means that the API key is invalid.

String token = FirebaseInstanceId.getInstance().getToken();
if (token == null || token.isEmpty()) {
    // API key is invalid
}

Step 2: Update the API key

If the API key is invalid, you need to update it. To update the API key, you can follow these steps:

  1. Go to the Firebase console and select your project.
  2. Click on the gear icon in the top left corner and select «Project settings».
  3. Click on the «Cloud Messaging» tab.
  4. Copy the «Server key» value.
  5. Open your Android Studio project and go to the app folder.
  6. Open the google-services.json file.
  7. Replace the api_key value with the «Server key» value that you copied from the Firebase console.
"api_key": [
    {
        "current_key": "YOUR_SERVER_KEY"
    }
]

Step 3: Refresh the token

After updating the API key, you need to refresh the token. To refresh the token, you can use the FirebaseInstanceId.getInstance().deleteInstanceId() method to delete the current token and then use the FirebaseInstanceId.getInstance().getToken() method to get a new token.

FirebaseInstanceId.getInstance().deleteInstanceId();
String token = FirebaseInstanceId.getInstance().getToken();

Method 4: Check for Invalid JSON Format

If you are facing Firebase 401 Unauthorized Error FCM, one of the reasons could be due to invalid JSON format. In this tutorial, we will show you how to fix this error by checking for invalid JSON format.

Step 1: Check for Invalid JSON Format

To check for invalid JSON format, you can use the JSONObject class in Android. Here is an example code snippet:

public boolean isValidJson(String json) {
    try {
        new JSONObject(json);
        return true;
    } catch (JSONException e) {
        return false;
    }
}

Step 2: Handle Invalid JSON Format

If the JSON format is invalid, you can handle it by logging the error or sending an error message to the server. Here is an example code snippet:

if (!isValidJson(json)) {
    Log.e(TAG, "Invalid JSON format: " + json);
    return;
}

Step 3: Send FCM Message

Assuming that the JSON format is valid, you can send the FCM message using the FirebaseMessaging class in Android. Here is an example code snippet:

FirebaseMessaging.getInstance().send(new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com")
        .setMessageId(Integer.toString(messageId))
        .addData("message", json)
        .build());

Method 5: Ensure Proper Permissions are Granted

To fix the Firebase 401 unauthorized error FCM in Android, you can ensure proper permissions are granted. Here are the steps to do it:

  1. Add the following dependencies to your app-level build.gradle file:
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation 'com.google.firebase:firebase-auth:19.3.2'
  1. In your AndroidManifest.xml file, add the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
  1. Create a FirebaseMessagingService class that extends FirebaseMessagingService. Override the onNewToken() method to handle token refresh:
public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onNewToken(String token) {
        Log.d("TAG", "Refreshed token: " + token);
        // Send the token to your server or update the user's preferences.
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        // Handle FCM messages here.
    }
}
  1. In your app-level build.gradle file, add the following service declaration:
  1. Finally, make sure that the Firebase Cloud Messaging API key and sender ID are properly configured in your Firebase project. You can find these values in the Firebase console under Project settings > Cloud messaging.

That’s it! With these steps, you should be able to fix the Firebase 401 unauthorized error FCM in Android by ensuring proper permissions are granted.

I’ve spent the first part of this year at work writing and testing a new Android application, and during the course of this I’ve stumbled across some devices which seem to have recurring issues with conenctivity to Google’s Firebase Cloud Messaging service. This issue manifests with the device no longer receiving notifications after being left to idle for a few hours. In this post, I’ll go over some troubleshooting steps that I’ve found.

Check Firebase Service Status

The first step to take is to double check that the Firebase Cloud Messaging service is not having any operational issues. This can be checked on the Firebase Status Dashboard — simply ensure that the Cloud Messaging service has a green tick next to it. There is also a handy RSS feed you can subscribe to for incidents, though there doesn’t seem to be any way to filter this to only report services you are actually using.

Check Your Device’s Connectivity to FCM

The next step is to check your device’s connectivity to Firebase Cloud Messaging itself.

This can be done from the Phone app, though it should be noted that your device may have a custom phone app from your manufacturer (this is definitely true for Samsung devices) — if this is the case, you need to install the Phone by Google app from the Google Play Store.

The steps to take are as follows:

  1. Open the Phone app.

  2. Open the dialler.

  3. Dial the following: *#*#426#*#*.

  4. The FCM Diagnostics screen should open as soon as you finish typing, without having to hit the call button — if it doesn’t appear, hit the call button. If nothing happens, you might be using a custom phone app from your device vendor (looking at you again Samsung…) in which case you need to install the Phone by Google app as explained above.

    The screen should look something like the below screenshot:

    Screenshot of the FCM Diagnostics screen showing as connected

There should be a line that says something like Server: Connected. If it says Not connected or something, then there should also be some information about the last close code and when the connection was lost.

You can also press the Events button to see a live trail of events relating to the connection, including incoming messages.

To see further information about the status, click on the menu button at the top right of the screen and check the Advanced view checkbox.

If the status shows FCM as disconnected and it doesn’t reconnect, you should check your firewall — see Google’s documentation on FCM ports and your firewall.

Unfortunately, I do still have a device which disconnects and steadfastly refuses to reconnect until it’s rebooted. Further troubleshooting is needed!

I am new to firebase and I want to implement Firebase Cloud Messaging(FCM) I am facing problem getting started with it. The firebase is not initializing. Thanks for helping.

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle (app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.sai_praneeth7777.hasportal"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.0.0'

    compile 'com.google.firebase:firebase-crash:9.2.0'
    compile 'com.google.firebase:firebase-messaging:9.2.0'

    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'com.google.code.gson:gson:2.4'

    compile 'com.android.support:cardview-v7:24.0.0'
}

apply plugin: 'com.google.gms.google-services'

This is the logcat

07-06 19:17:00.397 18894-18894/ D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
07-06 19:17:00.482 18894-18894/ W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9256000 but found 9080280
07-06 19:17:00.483 18894-18894/ I/DynamiteModule: Considering local module com.google.android.gms.flags:1 and remote module com.google.android.gms.flags:0
07-06 19:17:00.487 18894-18894/ I/DynamiteModule: Selected local version of com.google.android.gms.flags
07-06 19:17:00.501 18894-18894/ W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
07-06 19:17:00.501 18894-18894/ W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
07-06 19:17:00.510 18894-18894/ W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
07-06 19:17:00.517 18894-18894/ W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9256000 but found 9080280
07-06 19:17:00.517 18894-18894/ I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:0
07-06 19:17:00.527 18894-18894/ E/FirebaseCrash: Failed to initialize crash reporting
com.google.firebase.crash.internal.zzg$zza: com.google.android.gms.internal.zzsj$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzeh(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1686)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1655)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4964)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4559)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4499)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: com.google.android.gms.internal.zzsj$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.internal.zzsj.zza(Unknown Source)
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source) 
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source) 
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.google.firebase.FirebaseApp.zza(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source) 
at com.google.firebase.FirebaseApp.zzeh(Unknown Source) 
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1686) 
at android.content.ContentProvider.attachInfo(ContentProvider.java:1655) 
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
at android.app.ActivityThread.installProvider(ActivityThread.java:4964) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4559) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4499) 
at android.app.ActivityThread.access$1500(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5221) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
07-06 19:17:00.558 18894-18894/ I/FA: App measurement is starting up, version: 9256
07-06 19:17:00.558 18894-18894/ I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
07-06 19:17:00.618 18894-18894/ I/FirebaseInitProvider: FirebaseApp initialization successful
07-06 19:17:00.682 18894-18925/ W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9256000 but found 9080280
07-06 19:17:00.684 18894-18907/ I/art: Background partial concurrent mark sweep GC freed 2819(186KB) AllocSpace objects, 2(32KB) LOS objects, 53% free, 880KB/1904KB, paused 5.432ms total 47.807ms
07-06 19:17:00.700 18894-18894/ W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-06 19:17:00.855 18894-18927/ D/OpenGLRenderer: Render dirty regions requested: true
[ 07-06 19:17:00.881 18894:18894 D/         ]
HostConnection::get() New Host Connection established 0x7fe26aba3ec0, tid 18894
07-06 19:17:00.890 18894-18894/ D/Atlas: Validating map...
07-06 19:17:00.934 18894-18894/ W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
07-06 19:17:00.983 18894-18907/ W/art: Suspending all threads took: 14.572ms
[ 07-06 19:17:01.050 18894:18927 D/         ]
HostConnection::get() New Host Connection established 0x7fe26d476180, tid 18927
07-06 19:17:01.064 18894-18927/ I/OpenGLRenderer: Initialized EGL, version 1.4
07-06 19:17:01.101 18894-18927/ D/OpenGLRenderer: Enabling debug mode 0
07-06 19:17:10.845 18894-18925/ I/FA: Tag Manager is not found and thus will not be used
07-06 19:17:10.847 18894-18925/ W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9256000 but found 9080280
07-06 19:17:10.847 18894-18894/ W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
07-06 19:18:19.553 18894-19743/ W/FA: Tasks have been queued for a long time
07-06 19:18:19.930 18894-18902/ W/art: Suspending all threads took: 215.213ms
07-06 19:18:20.050 18894-18907/ I/art: Background sticky concurrent mark sweep GC freed 910(82KB) AllocSpace objects, 3(48KB) LOS objects, 11% free, 1679KB/1904KB, paused 80.391ms total 305.959ms
07-06 19:18:20.059 18894-18907/ W/art: Suspending all threads took: 6.418ms

Hope this info helps solving the problem

Понравилась статья? Поделить с друзьями:
  • Ошибка fcl на стиральной машине lg
  • Ошибка fciom c102715
  • Ошибка fc1 стиральной машинки haier что делать
  • Ошибка fc0 стиральная машина haier
  • Ошибка fbeo аристон