0

I've opened existing Firebase project, but i'm receiving error in Runtime.

                   Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.dji.GSDemo.GoogleMap. Make sure to call FirebaseApp.initializeApp(Context) first.

I've tried to "Connect to Firebase" using the Firebase Assistant, but getting:

Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.

I've tried updating stuff at SDK-Tools: sdk

But it's all up to date like another firebase project of mine that works.

My problem is caused because i've added Firebase Activities to existing non-firebase project.

This is my build gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
defaultConfig {

    ndk {
        abiFilters 'armeabi-v7a'
    }

    applicationId "com.dji.GSDemo.GoogleMap"
    minSdkVersion 23
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    //Enabling multidex support
    multiDexEnabled true //Mention in the doc

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

//Mention in the doc
dexOptions {
    incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g" // 2g should be also OK
}

packagingOptions{
    doNotStrip "*/*/libdjivideo.so"
    doNotStrip "*/*/libSDKRelativeJNI.so"
    doNotStrip "*/*/libFlyForbid.so"
    doNotStrip "*/*/libduml_vision_bokeh.so"
    doNotStrip "*/*/libyuv2.so"
    doNotStrip "*/*/libGroudStation.so"
    doNotStrip "*/*/libFRCorkscrew.so"
    doNotStrip "*/*/libUpgradeVerify.so"
    doNotStrip "*/*/libFR.so"
}
}
dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'

implementation 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.google.android.gms:play-services-gcm:11.8.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.firebaseui:firebase-ui-database:2.3.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.github.medyo:android-about-page:1.2.1'
implementation 'com.google.android.gms:play-services-places:11.8.0'
compile 'com.github.medyo:android-about-page:1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:cardview-v7:27.0.2'

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:animated-vector-drawable:27.0.2'
implementation 'com.android.support:mediarouter-v7:27.0.2'


compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:11.8.0'

compile ('com.dji:dji-sdk:4.4.1')
provided ('com.dji:dji-sdk-provided:4.4.1')
}

How can I solve it?

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
jonb
  • 845
  • 1
  • 13
  • 36
  • Possible duplicate of [Make sure to call FirebaseApp.initializeApp(Context) first](https://stackoverflow.com/questions/47887880/make-sure-to-call-firebaseapp-initializeappcontext-first) – Peter Haddad Feb 28 '18 at 10:52
  • Hi @PeterHaddad thanks, I've tried your solution and it didn't solve my problem This is my application in the manifest: And i've added in public class MApplication extends Application : public void onCreate() { super.onCreate(); FirebaseApp.initializeApp(this); fpvDemoApplication.onCreate(); } – jonb Feb 28 '18 at 10:58
  • did you create a new class and extend `Application class`? – Peter Haddad Feb 28 '18 at 11:01
  • Yes, i've also tried creating new application in the manifest, and then new class with only onCreate, but then all of the manifest didn't compile – jonb Feb 28 '18 at 11:03
  • @PeterHaddad if I open Then the rest of my Manifest file won't compile Where am I suppose to close it ? I alreay have And class public class MApplication extends Application { Which extends it, Tried to FirebaseApp.initializeApp(this) there but it didn't work... – jonb Feb 28 '18 at 11:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/165961/discussion-between-peter-haddad-and-johnsnowthedeveloper). – Peter Haddad Feb 28 '18 at 11:26

1 Answers1

1

Please check the link in the comment for this problem:

Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.dji.GSDemo.GoogleMap. Make sure to call FirebaseApp.initializeApp(Context) first.

For the second problem please update the firebaseui:

change this:

implementation 'com.firebaseui:firebase-ui-database:2.3.0'

to this:

implementation 'com.firebaseui:firebase-ui-database:3.2.2'

FirebaseUI compatibility

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • As I commented above, I've tried your solution of FirebaseApp.initializeApp(Context) and it's not solving my problem. and what is the 'second problem' you're talking about sir? I have one problem here In normal projects i'm able to Connect to Firebase, and then I don't have the error in runtime. I just need to solve the connection to Firebase – jonb Feb 28 '18 at 11:17
  • 1
    You are right, I see I have some compling issues in different place, thanks, trying to solve it – jonb Feb 28 '18 at 11:21