I'm trying to implement One Signal Push Notifications in my android app but I'm getting this Exception and I have been searching for hours but unfortunately nothing worked for me and this has never happened before, I have used One Signal in a lot of my apps with no issues. This one's just so frustrating..
I also get
message in One Signal.
E/OneSignal: Unknown error getting FCM Token
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId;
at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:60)
at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97)
at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37)
at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceId" on path: DexPathList[[zip file "/data/app/~~zRjRGY2wsxKq-i1gwd7a9A==/com.easytech.iraqipoultry-zKCq8MZEu_YqBbIIAwkQOw==/base.apk"],nativeLibraryDirectories=[/data/app/~~zRjRGY2wsxKq-i1gwd7a9A==/com.easytech.iraqipoultry-zKCq8MZEu_YqBbIIAwkQOw==/lib/x86, /system/lib, /system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:60)
at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97)
at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37)
at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84)
at java.lang.Thread.run(Thread.java:923)
The libraries I use
dependencies {
implementation ('com.akexorcist:localization:1.2.10') {
exclude group: 'androidx.core', module: 'core'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'com.android.volley:volley:1.2.0'
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
implementation 'com.kelin.translucentbar:library:0.8.0'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation 'com.github.gayanvoice:android-animations:1.0.2'
implementation 'com.github.razir.progressbutton:progressbutton:2.1.0'
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.intuit.sdp:sdp-android:1.0.5'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.akexorcist:localization:1.2.10'
implementation 'com.google.firebase:firebase-firestore:23.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.rishabhharit.roundedimageview:RoundedImageView:0.8.4'
implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:4.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}