无法连接到现有Android Studio项目中的Firebase
我已打开现有的Firebase项目,但在运行时收到错误无法连接到现有Android Studio项目中的Firebase,android,firebase,gradle,Android,Firebase,Gradle,我已打开现有的Firebase项目,但在运行时收到错误 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. 我已尝试使用Firebase助手连
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.
我已尝试使用Firebase助手连接到Firebase,但得到:
Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.
我尝试过在SDK工具中更新内容:
但这一切都是最新的,就像我的另一个firebase项目一样
导致我的问题的原因是,我已将Firebase活动添加到现有的非Firebase项目中
这是我的身材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')
}
如何解决此问题?请查看评论中有关此问题的链接: 原因:java.lang.IllegalStateException:默认FirebaseApp未在此进程com.dji.GSDemo.GoogleMap中初始化。确保首先调用FirebaseApp.initializeAppContext 对于第二个问题,请更新firebaseui: 更改此项:
implementation 'com.firebaseui:firebase-ui-database:2.3.0'
为此:
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
可能与Hi@PeterHaddad重复谢谢,我尝试了你的解决方案,但没有解决我的问题这是我在清单中的应用程序:并且我在公共类MApplication extensed应用程序中添加了:public void onCreate{super.onCreate;FirebaseApp.initializeapthis;fpvDemoApplication.onCreate;}您是否创建了一个新类和扩展应用程序类?是的,我还尝试在清单中创建新应用程序,然后仅使用onCreate创建新类,但所有清单都没有compile@PeterHaddad如果我打开,那么我的清单文件的其余部分将无法编译,我应该在哪里关闭它?我一直在使用类和公共类MapApplication扩展应用程序{这扩展了它,尝试了FirebaseApp.InitializeAppt,但它没有起作用…正如我在上面评论的,我尝试了你的FirebaseApp.initializeAppContext解决方案,但它没有解决我的问题。先生,你说的“第二个问题”是什么?我在正常项目中有一个问题,我可以连接到Firebase,然后我在运行时没有错误。我只需要解决与Firebase的连接。你是对的,我看到我在不同的地方有一些编译问题,谢谢,正在尝试解决它