我创建了一个新的项目,并通过firebase的android studio工具添加了firebase。按照指示做了一切,但我在午餐时得到了这个错误的应用程序。
Process: com.chitchat, PID: 20084
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chitchat/com.chitchat.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.chitchat. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.chitchat. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.1:219)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source:1)
at com.chitchat.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
MainActivity.java是
public class MainActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseApp.initializeApp(MainActivity.this);
mAuth = FirebaseAuth.getInstance();
}
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
//updateUI(currentUser);
if(currentUser == null){
Intent startAct = new Intent(MainActivity.this, Start_Activity.class);
startActivity(startAct);
finish();
}
}
}
而gradle.build是
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.chitchat"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
//implementation 'com.google.android.gms:play-services-base'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
项目级分级。Build
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在网上找不到任何东西!已添加FirebaseApp.InitializeApp(this)
,这在任何说明中都没有,但在模拟器和设备上仍然存在相同的错误。
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.2.0'
我在Visual Studio2019中有一个Xamarin表单解决方案。我现在只使用Android版本。完整的错误是: 在此进程中,java.lang.IllegalStateException Message=Default FirebaseApp未初始化AppCardView.Sample.android。确保首先调用FirebaseApp.InitializeApp(上下文)。 在我的An
我正在开发一个Android程序,使用Firebase数据库,但我现在有问题。 这是我的代码主要活动:
甚至我也调用了FirebaseApp.InitializeApp(this);在很多地方 MyApplication(扩展应用程序),在活动的onCreate中调用
我在使用FirebaseUI时遇到了麻烦。当我运行我的应用程序时,出现以下问题:“默认FirebaseApp在此进程中未初始化。请确保首先调用FirebaseApp.InitializeApp(上下文)。” 在我的应用程序/构建中。Gradle我有依赖: 、 、 、 我已经将GoogleServices.json导出到“app”文件夹。我别无选择,问题还在继续。有什么建议吗? logcat: -
我正在尝试使用Firebase存储下载图像。我编写了以下代码 MainActivity.java 我在这个论坛上搜索,但没有得到什么是确切的问题。请帮忙。日志行:
我正在努力在一个成熟的MVVMcross应用程序中实现谷歌的Firebase推送通知。我们被迫寻求一个新的解决方案,我们目前的一个,因为它似乎在AppCenter的功能即将被否决。 我们已经将代码放在RootActivity文件中(在方法的底部) 当我在我的Android Galaxy上的USB/Debug场景中运行该应用程序时,我得到当前错误“默认FirebaseApp未在此过程中初始化” 我试