@newdancer

Не приходят push через GCM, возращается ошибка Firebase Crash Reporting?

Не приходят push через GCMб возращается ошибка Firebase Crash Reporting?
Ошибка имеет вид:
Fatal error
java.lang.RuntimeException
First seen version
21
File
ActivityThread.java
Exception message
java.lang.RuntimeException: Unable to start activity ComponentInfo{..MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.graphics.drawable.DrawerArrowDrawable.setVerticalMirror(boolean)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)

mainActivity имеет вид
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        mActionBar = getSupportActionBar();
        float elevation = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, getResources()
                .getDimension(R.dimen.base_padding_margin_4dp), getResources().getDisplayMetrics());
        mActionBar.setElevation(elevation);
        initializePush();
        init();
    }

    private void initializePush() {
        //Initializing our broadcast receiver
        mRegistrationBroadcastReceiver = new BroadcastReceiver() {

            //When the broadcast received
            //We are sending the broadcast from GCMRegistrationIntentService

            @Override
            public void onReceive(Context context, Intent intent) {
                //If the broadcast has received with success
                //that means device is registered successfully
                if (intent.getAction().equals(GCMRegistrationIntentService.REGISTRATION_SUCCESS)) {
                    //Getting the registration token from the intent
                    String token = intent.getStringExtra("token");
                    //Displaying the token as toast
                    //Toast.makeText(getApplicationContext(), "Registration token:" + token, Toast.LENGTH_LONG).show();

                    //if the intent is not with success then displaying error messages
                } else if (intent.getAction().equals(GCMRegistrationIntentService.REGISTRATION_ERROR)) {
                    Toast.makeText(getApplicationContext(), "GCM registration error!", Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(getApplicationContext(), "Error occurred", Toast.LENGTH_LONG).show();
                }
            }
        };

        //Checking play service is available or not
        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());

        //if play service is not available
        if (ConnectionResult.SUCCESS != resultCode) {
            //If play service is supported but not installed
            if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
                //Displaying message that play service is not installed
                Toast.makeText(getApplicationContext(), "Google Play Service is not install/enabled in this device!", Toast.LENGTH_LONG).show();
                GooglePlayServicesUtil.showErrorNotification(resultCode, getApplicationContext());

                //If play service is not supported
                //Displaying an error message
            } else {
                Toast.makeText(getApplicationContext(), "This device does not support for Google Play Service!", Toast.LENGTH_LONG).show();
            }

            //If play service is available
        } else {
            //Starting intent to register device
            Intent itent = new Intent(this, GCMRegistrationIntentService.class);
            startService(itent);
        }
    }

может кто знает что не так. Сообщений отправляются, но на телефон не доходят. Ночью присылает firebase ошибку
  • Вопрос задан
  • 210 просмотров
Пригласить эксперта
Ответы на вопрос 1
@AlimNinja
Android Developer
Попробуйте использовать Firebase вместо GCM. GCM старым способ получения Push-уведомлений. С Firebase удобнее работать https://firebase.google.com/docs/cloud-messaging/
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы