这条线让我的 firebase 注册应用程序崩溃了......**mFirebaseAuth = FirebaseAuth.getInstance();**
This line is crashing my firebase signup app.....**mFirebaseAuth = FirebaseAuth.getInstance();**
当我删除此行时 mFirebaseAuth = FirebaseAuth.getInstance(); 然后 activity_signup.xml 运行 在我的 android工作室,但当我 运行
带有此行的程序然后停止工作并崩溃。
既然没有它就无法开发应用程序,应该怎么办?
程序其他部分的一些依赖项,例如 位置、短信、上传图片
这是我的SignUp.java
public class SignupActivity extends AppCompatActivity {
EditText emailId, password;
Button btnSignUp;
TextView tvSignIn;
FirebaseAuth mFirebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
mFirebaseAuth = FirebaseAuth.getInstance();
emailId=findViewById(R.id.editText);
password=findViewById(R.id.editText2);
btnSignUp=findViewById(R.id.button);
tvSignIn=findViewById(R.id.textView);
}
}
这是我的 Build.gradle(app)
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.example.getlocation"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-messaging:20.2.3'
implementation 'com.google.firebase:firebase-firestore:21.5.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.android.gms:play-services-auth:10.0.1'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
这是我在 运行 部分遇到的错误,第 29 行正在初始化 FirebaseAuth 实例
Process: com.example.getlocation, PID: 11123
java.lang.NoSuchMethodError: No virtual method zzbqp()Ljava/lang/String; in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.example.getlocation-2/base.apk)
at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at com.example.getlocation.SignupActivity.onCreate(SignupActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6852)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2766)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1513)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6210)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
您使用的是这些依赖项的非常旧版本:
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
您应该确保 所有 的 Firebase 依赖项都是 release notes in the documentation 所述的最新版本。它们通常应该一起升级。
当我删除此行时 mFirebaseAuth = FirebaseAuth.getInstance(); 然后 activity_signup.xml 运行 在我的 android工作室,但当我 运行 带有此行的程序然后停止工作并崩溃。
既然没有它就无法开发应用程序,应该怎么办?
程序其他部分的一些依赖项,例如 位置、短信、上传图片
这是我的SignUp.java
public class SignupActivity extends AppCompatActivity {
EditText emailId, password;
Button btnSignUp;
TextView tvSignIn;
FirebaseAuth mFirebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
mFirebaseAuth = FirebaseAuth.getInstance();
emailId=findViewById(R.id.editText);
password=findViewById(R.id.editText2);
btnSignUp=findViewById(R.id.button);
tvSignIn=findViewById(R.id.textView);
}
}
这是我的 Build.gradle(app)
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.example.getlocation"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-messaging:20.2.3'
implementation 'com.google.firebase:firebase-firestore:21.5.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.android.gms:play-services-auth:10.0.1'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
这是我在 运行 部分遇到的错误,第 29 行正在初始化 FirebaseAuth 实例
Process: com.example.getlocation, PID: 11123
java.lang.NoSuchMethodError: No virtual method zzbqp()Ljava/lang/String; in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.example.getlocation-2/base.apk)
at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at com.example.getlocation.SignupActivity.onCreate(SignupActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6852)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2766)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1513)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6210)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
您使用的是这些依赖项的非常旧版本:
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
您应该确保 所有 的 Firebase 依赖项都是 release notes in the documentation 所述的最新版本。它们通常应该一起升级。