我已打开现有的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.
但是这一切都像我的另一个火力棒项目一样有效。
我的问题是因为我已将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')
}
我该如何解决?
答案 0 :(得分:1)
请检查此问题的评论中的链接:
引起:java.lang.IllegalStateException:默认FirebaseApp未在此过程com.dji.GSDemo.GoogleMap中初始化。请务必先调用FirebaseApp.initializeApp(Context)。
对于第二个问题,请更新firebaseui:
改变这个:
<div id="dogmod" class="modal">
<center>
<form class="modal-content animate" style="margin: 0; padding-left:50px; padding-right:50px; padding-bottom:50px;">
<div class="imgcontainer">
<span onclick="document.getElementById('dogmod').style.display='none'" class="close" title="Close">×</span>
<h1 align=center>Description</h1>
<?php echo '<img src="data:image/jpeg;base64,'.base64_encode($_SESSION['petimg'] ).'" style="margin-top:50px;float:left; margin-right:50px;"/>'; ?>
<h1 style="margin-top:50px;margin-bottom:50px">
<?php echo $_SESSION['petname'] ;?>
</h1>
<p style="margin-bottom:50px;">
<?php echo $_SESSION['petdesc'] ;?>
</p>
<input type="button" value="Back" onclick=location.href='doga.php' class="button_1" style=" width: auto;padding: 10px 18px; background-color: #f44336; border:0px; color:white;">
<h2> </h2>
</form>
</center>
<script>
// Get the modal
var modal = document.getElementById('dogmod');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</div>
到此:
implementation 'com.firebaseui:firebase-ui-database:2.3.0'