Hello.
why am i getting recently this error? I used push notification in the app
“Default FirebaseApp is not initialized in this process Make sure to call FirebaseApp.initializeApp(Context) first.”
Have you followed steps that are shown in the doc https://backendless.com/docs/android/push_push_notification_setup_androi.html
I did according to the doc i get error:
Default FirebaseApp is not initialized in this process com.forodja.app. Make sure to call FirebaseApp.initializeApp(Context) first.
this code is Application class:
class RxApp: Application() {
companion object {
lateinit var INSTANCE: RxApp
fun applicationContext(): Context {
return INSTANCE.applicationContext
}
}
override fun onCreate() {
super.onCreate()
INSTANCE = this
val context: Context = applicationContext()
Timber.plant(Timber.DebugTree())
FirebaseApp.initializeApp(this)
Backendless.setUrl(Const.BACKENDLESS_SERVER_URL)
Backendless.initApp(context,Const.BACKENDLESS_APPLICATION_ID, Const.BACKENDLESS_API_KEY)
}
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
MultiDex.install(this)
}
}
and this code is manifest.xml:
<?xml version="1.0" encoding="utf-8"?><uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:name="com.forodja.app.diff.RxApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.forodja.app.ui.SplashRegisterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.forodja.app.ui.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<receiver android:name="com.forodja.app.diff.SmsOtpReceiver" android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED"/>
</intent-filter>
</receiver>
<service android:name="com.backendless.push.BackendlessFCMService" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
and this library in my buld.gradle:
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation "com.backendless:backendless:5.3.0"
implementation('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
Did you follow the link in the docs for setting up FCM in your app?
Did you go through the steps 3 and 4 (build.gradle configuration to enable google services)? Seems that this is the actual cause of the problem.
BTW: if everything is configured correctly - there is no necessity in calling FirebaseApp.initializeApp(Context) anywhere in your code
Regards,
Anton
i solve it:
i downgrade google-service version in build.gardle(project).
that version was
classpath 'com.google.gms:google-services:4.3.0'
but for solved this i downgrade to
classpath 'com.google.gms:google-services:4.2.0' // Google Services plugin
I was not able to reproduce the issue with
classpath 'com.google.gms:google-services:4.3.0'
but I have the issue if I do not add this line.
I have the following version of sdk:
minSdkVersion 27
targetSdkVersion 28
What version do you have?