title: Android: FirebaseMessaging.getToken() on a null object reference
body: <p>I'm having problems using onesignal. I tried to use onesignal on another project and it worked but on this project i get error. I guess some libraries are causing this problem.</p>
  <p><strong>App Gradle</strong></p>
  <pre><code>plugins {
  id 'com.android.application'
  id 'kotlin-android'
  id 'androidx.navigation.safeargs'
  id 'kotlin-kapt'
  id 'com.google.gms.google-services'
  id 'com.onesignal.androidsdk.onesignal-gradle-plugin'}
  
  android {
  compileSdkVersion 30
  buildToolsVersion &quot;30.0.3&quot;
  
  buildFeatures {
      viewBinding true
  }
  
  defaultConfig {
      applicationId &quot;com.ersincoskun.focusapp&quot;
      minSdkVersion 21
      targetSdkVersion 30
      versionCode 1
      versionName &quot;1.0&quot;
  
      testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
  }
  
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
      }
  }
  compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
  }
  kotlinOptions {
      jvmTarget = '1.8' }
  }       
  dependencies {
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  implementation files('libs\\YouTubeAndroidPlayerApi.jar')
  def nav_version = &quot;2.3.4&quot;
  
  implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version&quot;
  implementation 'androidx.core:core-ktx:1.3.2'
  implementation 'androidx.appcompat:appcompat:1.2.0'
  implementation 'com.google.android.material:material:1.4.0-alpha02'
  implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  testImplementation 'junit:junit:4.+'
  androidTestImplementation 'androidx.test.ext:junit:1.1.2'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
  
  implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
  implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
  implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
  
  implementation 'de.hdodenhof:circleimageview:3.1.0'
  
  implementation 'com.github.AppIntro:AppIntro:6.1.0'
  
  implementation 'com.akexorcist:round-corner-progress-bar:2.1.1'
  
  implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2.3'
  
  def room_version = &quot;2.3.0&quot;
  
  implementation &quot;androidx.room:room-ktx:$room_version&quot;
  implementation &quot;androidx.room:room-runtime:$room_version&quot;
  kapt &quot;androidx.room:room-compiler:$room_version&quot;
  
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'
  
  def lifecycle_version = &quot;2.3.1&quot;
  
  // ViewModel
  implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version&quot;
  implementation 'androidx.activity:activity-ktx:1.3.1'
  // LiveData
  implementation &quot;androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version&quot;
  implementation &quot;androidx.lifecycle:lifecycle-extensions:2.2.0&quot;
  implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1&quot;
  //retrofit
  def retrofitVersion = '2.9.0'
  implementation &quot;com.squareup.retrofit2:retrofit:$retrofitVersion&quot;
  implementation &quot;com.squareup.retrofit2:converter-gson:$retrofitVersion&quot;
  
  implementation 'me.tankery.lib:circularSeekBar:1.3.0'
  implementation 'com.mikhaellopez:circularprogressbar:3.0.3'
  
  implementation &quot;androidx.lifecycle:lifecycle-reactivestreams-ktx:2.4.0-alpha01&quot;
  implementation &quot;io.reactivex.rxjava2:rxandroid:2.1.1&quot;
  
  implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
  
  implementation 'com.eightbitlab:blurview:1.6.6'
  
  implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
  
  implementation 'com.github.bumptech.glide:glide:4.12.0'
  
  implementation 'com.github.MdFarhanRaja:SearchableSpinner:2.0'
  
  implementation platform('com.google.firebase:firebase-bom:28.3.0')
  implementation 'com.google.firebase:firebase-analytics-ktx'
  
  implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
  implementation &quot;com.google.firebase:firebase-iid&quot;}
  </code></pre>
  <p><strong>Top Level Gradle</strong></p>
  <pre><code>buildscript {
  ext.kotlin_version = &quot;1.5.10&quot;
  repositories {
      google()
      jcenter()
      gradlePluginPortal()
      mavenCentral()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:7.0.0'
      classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
      classpath 'com.google.gms:google-services:4.3.9'
      classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
  
      def nav_version = &quot;2.3.4&quot;
      classpath &quot;androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version&quot;
  
      // NOTE: Do not place your application dependencies here; they belong
      // in the individual module build.gradle files}
  }
  allprojects {
  repositories {
      google()
      jcenter()
      mavenCentral()
  
      maven { url 'https://jitpack.io' } 
  }
  }
  task clean(type: Delete) {
  delete rootProject.buildDir
  }
  </code></pre>
  <p><strong>Manifest</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  package=&quot;com.ersincoskun.focusapp&quot;&gt;
  
  &lt;uses-permission android:name=&quot;android.permission.FOREGROUND_SERVICE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
  &lt;uses-permission
      android:name=&quot;android.permission.PACKAGE_USAGE_STATS&quot;
      tools:ignore=&quot;ProtectedPermissions&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.SYSTEM_ALERT_WINDOW&quot; /&gt;
  &lt;uses-permission
      android:name=&quot;android.permission.INTERNAL_SYSTEM_WINDOW&quot;
      tools:ignore=&quot;ProtectedPermissions&quot; /&gt;
  
  &lt;application
      android:name=&quot;.MyApplicationClass&quot;
      android:allowBackup=&quot;false&quot;
      android:icon=&quot;@mipmap/ic_launcher&quot;
      android:label=&quot;Focused Pupa&quot;
      android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
      android:supportsRtl=&quot;true&quot;
      android:theme=&quot;@style/Theme.FocusApp&quot;
      android:usesCleartextTraffic=&quot;true&quot;
      tools:node=&quot;replace&quot;&gt;
      &lt;activity
          android:name=&quot;com.ersincoskun.focusapp.view.fragments.watchvideo.FullScreenVideoActivity&quot;
          android:screenOrientation=&quot;sensorLandscape&quot;&gt;
  
      &lt;/activity&gt;
  
      &lt;service android:name=&quot;com.ersincoskun.focusapp.service.SessionService&quot; /&gt;
  
      &lt;activity android:name=&quot;com.ersincoskun.focusapp.view.activities.NotificationActivity&quot; /&gt;
      &lt;activity
          android:name=&quot;com.theartofdev.edmodo.cropper.CropImageActivity&quot;
          android:theme=&quot;@style/Base.Theme.AppCompat&quot; /&gt;
      &lt;activity
          android:name=&quot;com.ersincoskun.focusapp.view.activities.MainActivity&quot;
          android:screenOrientation=&quot;portrait&quot;
          android:windowSoftInputMode=&quot;adjustResize&quot; /&gt;
      &lt;activity
          android:name=&quot;com.ersincoskun.focusapp.view.activities.RegisterActivity&quot;
          android:screenOrientation=&quot;portrait&quot;
          android:windowSoftInputMode=&quot;adjustPan&quot; /&gt;
  
      &lt;activity android:name=&quot;com.ersincoskun.focusapp.view.activities.IntroActivity&quot; /&gt;
  
      &lt;activity
          android:name=&quot;com.ersincoskun.focusapp.view.activities.SplashScreen&quot;
          android:screenOrientation=&quot;portrait&quot;&gt;
          &lt;intent-filter&gt;
              &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
              &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;provider
          android:name=&quot;androidx.core.content.FileProvider&quot;
          android:authorities=&quot;${applicationId}.provider&quot;
          android:exported=&quot;false&quot;
          android:grantUriPermissions=&quot;true&quot;&gt;
          &lt;meta-data
              android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot;
              android:resource=&quot;@xml/provider_path&quot; /&gt;
      &lt;/provider&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p><strong>Application Class</strong></p>
  <pre><code>import android.app.Application
  import com.onesignal.OneSignal
  import androidx.work.Configuration
  
  class MyApplicationClass : Application(),Configuration.Provider {
  private val ONESIGNAL_APP_ID = &quot;xxxxxxxxxxxxxxxxxxxxxxx&quot;
  
  override fun onCreate() {
      super.onCreate()
  
      // Enable verbose OneSignal logging to debug issues if needed.
      OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE)
  
      // OneSignal Initialization
      OneSignal.initWithContext(this)
      OneSignal.setAppId(ONESIGNAL_APP_ID)
  }
  
  override fun getWorkManagerConfiguration() =
      Configuration.Builder()
          .setMinimumLoggingLevel(android.util.Log.INFO)
          .build()
  }
  </code></pre>
  <p><strong>Stacktrace</strong></p>
  <p>i get these errors what should i do to resolve please help me</p>
  <p><a href="https://i.stack.imgur.com/dzVXs.png" rel="nofollow noreferrer">my stacktrace</a></p>