title: Firebase not working on my android project
body: <p>I am trying to use Firebase  crash reporting and notifications on an Android Project I inherited from my predecessor in my place of work.</p>
  
  <p>For some unknown reason Firebase or OneSignal has refused to work on the project,it doesn't matter whether the app is in background or not. I implemented Firebase using the Android Studio Assistant.</p>
  
  <p>However if I create fresh projects and implement Firebase or OneSignal it works glitchlessly.</p>
  
  <p><strong>Module build.gradle</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 25
      buildToolsVersion '25.0.2'
  
  
      defaultConfig {
          applicationId "com.myfirm.appname"
          minSdkVersion 16
          targetSdkVersion 25
          versionCode 1
          versionName "1.0"
      }
      aaptOptions {
          additionalParameters "--no-version-vectors"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  repositories {
      mavenCentral()
  }
  dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      compile 'com.facebook.android:facebook-android-sdk:4.20.0'
      compile 'de.hdodenhof:circleimageview:1.3.0'
      compile 'com.android.volley:volley:1.0.0'
      compile 'com.squareup.picasso:picasso:2.5.0'
      compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
      compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
      compile 'com.android.support:design:25.3.0'
      compile 'com.android.support:customtabs:25.3.0'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      compile 'com.android.support:cardview-v7:25.3.0'
      compile 'com.android.support:support-v4:25.3.0'
      compile 'com.android.support:appcompat-v7:25.3.0'
      compile 'com.google.firebase:firebase-crash:10.0.1'
      compile 'com.onesignal:OneSignal:3.4.3'
      compile 'com.google.android.gms:play-services-gcm:10.0.1'
      compile 'com.google.android.gms:play-services-location:10.0.1'
      compile 'com.google.firebase:firebase-messaging:10.0.1'
      testCompile 'junit:junit:4.12'
  }
  
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p><strong>Project build.gradle</strong></p>
  
  <pre><code>// 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.3.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()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.myfirm.appname"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_SETTINGS" /&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  
      &lt;application
          android:name=".App"
          android:allowBackup="true"
          android:icon="@drawable/notification_icon"
          android:label="@string/app_name"
          android:largeHeap="true"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"
          tools:node="replace"&gt;
  
          &lt;service
              android:name=".services.TokenService"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  
          &lt;meta-data android:name="onesignal_app_id" android:value="@string/onesignal_app_id" tools:replace="android:value"/&gt;
          &lt;meta-data android:name="onesignal_google_project_number" android:value="@string/onesignal_google_project_number" tools:replace="android:value"/&gt;
  
          &lt;meta-data
              android:name="com.facebook.sdk.ApplicationId"
              android:value="@string/facebook_appid" /&gt;
  
  
          &lt;activity
              android:name="com.facebook.FacebookActivity"
              android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.Translucent.NoTitleBar" /&gt;
          &lt;activity
              android:name="com.facebook.CustomTabActivity"
              android:exported="true"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.VIEW" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
                  &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
  
                  &lt;data android:scheme="fbXXXXXXXXXXXX" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          // More Activities
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>MyApplication</strong></p>
  
  <pre><code>@Override
      public void onCreate() {
          super.onCreate();
          OneSignal.setLogLevel(OneSignal.LOG_LEVEL.DEBUG, OneSignal.LOG_LEVEL.NONE);
          FirebaseApp.initializeApp(this);
          // Removed some code
          OneSignal.startInit(this)
                  .setNotificationReceivedHandler(new OneSignalMessageReceiver())
                  .init();
      }
  </code></pre>
  
  <p>A few things to note:</p>
  
  <ol>
  <li><p>The app is always in background (I launched it and pressed the home button) when I send the notifications.</p></li>
  <li><p>On the dashboards (both Firebase and OneSignal), the message says it's been successfully sent.</p></li>
  <li><p>I'm getting the device token on Firebase and I uses it to send notifications. Sometimes it says notification has been sent and at other times it says token not registered.</p></li>
  <li><p>The reason why it appears I'm using both Firebase and OneSignal is because I tried Firebase first, it didn't work. Then I used OneSignal hoping hat it would Work but it didn't. So if any one works, I remove the other.</p></li>
  <li><p>The <code>google-services.json</code> exists in <em>ProjectName > app</em> and yes, the package name correspond with that in manifest.</p></li>
  <li><p>The crash reports are not showing on Firebase dashboard even when the app has crashed severally.</p></li>
  </ol>