12
respostas

Meu tokeon nao aparece no Log

Já recorri a outros tópicos do forum para tentar solucionar meu problema mas nao deu certo.

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.agendaweb">

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AgendaWeb">
        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="title_activity_formulario" />

        <receiver android:name=".receiver.SMSReceiver">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

        <activity android:name=".ProvasActivity" />
        <activity android:name=".DetalhesProvaActivity" />
        <activity android:name=".ProvasTabletActivity" />

        <service
            android:name=".firebase.AgendaMessagingService"
            android:stopWithTask="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="google_maps_key" />

        <activity android:name=".MapaActivity"></activity>
    </application>


</manifest>
12 respostas

build gradle module app

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

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.agendaweb"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        exclude 'META-INF/LICENSE'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    implementation 'com.squareup.retrofit2:converter-jackson:2.5.0'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.google.firebase:firebase-bom:26.2.0'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

AgendaMessagingService.class

package com.example.agendaweb.firebase;

import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;


public class AgendaMessagingService extends FirebaseMessagingService {
    @Override
    public void onNewToken(String token) {
        Log.d("token firebase", "Refreshed token: " + token);
        // TODO: Implement this method to send any registration to your app's servers.
        enviaTokenParaServidor(token);
    }

    private void enviaTokenParaServidor(String token) {

    }


}

Log (opc Debug selecionada e pesquisado somente "Firebase)

2021-02-03 15:54:07.979 16000-16000/com.example.agendaweb D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
2021-02-03 15:54:07.980 16000-16000/com.example.agendaweb D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
2021-02-03 15:54:07.981 16000-16000/com.example.agendaweb D/FirebaseApp: com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization.
2021-02-03 15:54:07.982 16000-16000/com.example.agendaweb I/FirebaseInitProvider: FirebaseApp initialization successful

Matheus, tudo bem ?

Cara no caso tu precisa colocar no filtro apenas seu app e o ideal é usar o campo de busca para buscar pela chave que tu colocou.

Olá, coloquei o filtro do App e coloquei na pesquisa apenas o inicio do Log que aparece com o Token na aula, para achar ele mais rapido, coloquei: "token" e apareceu isso no Log:

2021-02-04 14:00:01.997 5966-6062/? D/OlmAppSessionManager: AppFirstActivityPostResumed com.microsoft.office.outlook.boothandlers.BootTokenRefresher isInForeground false
2021-02-04 14:00:02.014 5966-6062/? I/OutlookCoreJobCreator: Is FCM token valid: true
2021-02-04 14:00:02.026 5966-6062/? D/BackgroundWorkSchedulerImpl: received work infos for tag: AC_FcmTokenUpdateJob
    [WorkInfo{mId='0a8ca6a3-7d57-42ba-abc9-5093c0fe8063', mState=SUCCEEDED, mOutputData=Data {}, mTags=[AC_FcmTokenUpdateJob, com.microsoft.office.outlook.fcm.ACFcmTokenUpdateJob], mProgress=Data {}}, WorkInfo{mId='793f7a71-cf0e-4f51-b268-916d9c23f53b', mState=SUCCEEDED, mOutputData=Data {}, mTags=[AC_FcmTokenUpdateJob, com.microsoft.office.outlook.fcm.ACFcmTokenUpdateJob], mProgress=Data {}}]
2021-02-04 14:00:02.105 5966-6062/? I/FcmTokenReaderWriter: isPushSyncAvailable: Token[true] PlaySvc[true] ForceUnavailable[false]
2021-02-04 14:00:02.460 5966-6068/? I/ADALUtil: Acquire token for account 32769 with resource 394866fc-eedb-4f01-8536-3ff84b16be2a
2021-02-04 14:00:02.494 5966-6126/? I/outlook.Accounts: ADALOAuth2TokenCache: [2021-02-04 17:00:02 - {"thread_id":"7911","correlation_id":"d99a1110-2de4-439a-8a31-beefe00395fd"}] Context is an Application? [true] Android 27 (null) - null
2021-02-04 14:00:02.911 5966-6126/? I/outlook.Accounts: TokenCacheItem: [2021-02-04 17:00:02 - d99a1110-2de4-439a-8a31-beefe00395fd] Check token expiration time. ver:3.1.2 Android 27 (null) - null
2021-02-04 14:00:04.300 5966-6002/? D/MgdDataSourceBase: refreshAuthTokenForUpn
2021-02-04 14:04:52.182 5966-6052/? D/AccessTokenRefreshRunnable: Running the refresh ...

Se não me engano, a chave não pode ter espaço

muda para : "tokenFirebaseTeste"

onde devo mudar isso?

estava assim:

        Log.d("token firebase", "Refreshed token: " + token);

Deve ficar assim:

        Log.d("tokenFirebaseTeste", "Refreshed token: " + token);

Agora, filtrando"token" nao aparece nada, mas filtrando por "firebase" aparece isso:

2021-02-04 14:18:09.620 10724-10749/com.example.agendaweb W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-02-04 14:18:09.639 10724-10751/com.example.agendaweb W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-02-04 14:18:09.644 10724-10724/com.example.agendaweb D/FirebaseApp: com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization.
2021-02-04 14:18:09.644 10724-10724/com.example.agendaweb I/FirebaseInitProvider: FirebaseApp initialization successful
2021-02-04 14:18:09.649 10724-10751/com.example.agendaweb I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
2021-02-04 14:18:09.649 10724-10751/com.example.agendaweb I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2021-02-04 14:18:09.787 10724-10756/com.example.agendaweb I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader az[DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/00000254/DynamiteModulesC.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000254/n/arm64-v8a, /system/lib64, /system/vendor/lib64]]]
2021-02-04 14:18:09.788 10724-10756/com.example.agendaweb I/FirebaseCrash: FirebaseCrash reporting loaded - com.google.android.gms.internal.crash.zzo@c5a7590
2021-02-04 14:18:09.875 10724-10757/com.example.agendaweb I/FirebaseCrashApiImpl: FirebaseCrash reporting API initialized
2021-02-04 14:18:09.876 10724-10757/com.example.agendaweb I/FirebaseCrash: FirebaseCrash reporting initialized com.google.android.gms.internal.crash.zzo@c5a7590
2021-02-04 14:18:09.877 10724-10757/com.example.agendaweb W/FirebaseCrashAnalytics: Unable to log event, missing Google Analytics for Firebase library
2021-02-04 14:18:23.645 10724-10901/com.example.agendaweb I/FirebaseCrash: Sending crashes

Reinicia o emulador e o android studio, as vezes o adb perde conexão e além disso, é bom pra dar um clean no logcat.

Outro detalhe mega importante é seu emulador ter play services.

Eu to usando a depuração direto pelo celular via cabo USB

Reiniciei o computador e aparece o seguinte no Log ao filtrar por "firebase"

2021-02-04 15:25:50.409 27010-27050/com.example.agendaweb W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-02-04 15:25:50.427 27010-27053/com.example.agendaweb W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-02-04 15:25:50.462 27010-27053/com.example.agendaweb I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
2021-02-04 15:25:50.462 27010-27053/com.example.agendaweb I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2021-02-04 15:25:50.474 27010-27010/com.example.agendaweb D/FirebaseApp: com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization.
2021-02-04 15:25:50.474 27010-27010/com.example.agendaweb I/FirebaseInitProvider: FirebaseApp initialization successful
2021-02-04 15:25:50.776 27010-27057/com.example.agendaweb I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader az[DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/00000254/DynamiteModulesC.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000254/n/arm64-v8a, /system/lib64, /system/vendor/lib64]]]
2021-02-04 15:25:50.777 27010-27057/com.example.agendaweb I/FirebaseCrash: FirebaseCrash reporting loaded - com.google.android.gms.internal.crash.zzo@bcf659a
2021-02-04 15:25:50.937 27010-27058/com.example.agendaweb I/FirebaseCrashApiImpl: FirebaseCrash reporting API initialized
2021-02-04 15:25:50.939 27010-27058/com.example.agendaweb I/FirebaseCrash: FirebaseCrash reporting initialized com.google.android.gms.internal.crash.zzo@bcf659a
2021-02-04 15:25:50.939 27010-27058/com.example.agendaweb W/FirebaseCrashAnalytics: Unable to log event, missing Google Analytics for Firebase library
2021-02-04 15:26:02.824 27010-27263/com.example.agendaweb I/FirebaseCrash: Sending crashes