【发布时间】:2023-04-08 16:01:02
【问题描述】:
Firebase 昨天工作得很好,但我今天早上打开我的项目只是发现 FirebaseAuth 类现在没有任何对 FirebaseUser 类的引用。我找不到getCurrentUser() 方法。
不过是班上的Google doc still shows that it exists!
我在那个班级的imports:
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GetTokenResult;
import com.google.firebase.auth.GoogleAuthProvider;
build.gradle:
api 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-admin:6.3.0'
是的:
- 我的
build.gradle中有apply plugin: 'com.google.gms.google-services' - 我的应用程序的
build.gradle中包含repositories { google() jcenter() } - 我有
Clean我的项目没有出错 - 我已经重启
AndroidStudio
我的应用程序中的当前错误(似乎从昨天开始就突然出现):
-
getCurrentUser()方法在我的FirebaseAuth类(已导入)中不再存在。其signInWithCredential(...)、signOut()、createUserWithEmailAndPassword(...)和signInWithEmailAndPassword(...)方法也是如此。 -
isEmailVerified()方法在我的FirebaseUser类中不再存在 - 尝试
Make Project时,我收到此错误:Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - auto-value-1.4.jar (com.google.auto.value:auto-value:1.4) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.。 -
build.gradle的implementation 'com.android.support:appcompat-v7:27.1.1'现在突出显示为错误 (All com.android.support librairies must have the same version specification)
我的完整build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.payne.simpletestapp"
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
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'
api 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-admin:6.3.0'
implementation 'org.osmdroid:osmdroid-android:6.0.1'
implementation 'org.osmdroid:osmdroid-wms:6.0.1'
implementation 'org.osmdroid:osmdroid-mapsforge:6.0.1'
implementation 'org.osmdroid:osmdroid-geopackage:6.0.1'
api 'com.github.MKergall:osmbonuspack:6.5.1'
implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
api 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation 'com.squareup.picasso:picasso:2.71828'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
apply plugin: 'com.google.gms.google-services'
请帮忙?我花了几天时间来构建这个类,但现在它不起作用。
【问题讨论】:
-
请注意,
firebase-admin旨在用于服务器,而不是 Android 应用程序。见stackoverflow.com/a/42103063/4815718 -
从
build.gradle中删除firebase-admin并按Sync now解决了问题!奇怪:我什至把它放回那里只是为了测试它,项目很好。 (从那以后我再次删除它。我一直想知道这是否只在服务器端需要。)当你在这里时,你介意我问一下:我应该把我的firebase-adminsdk.json和@987654359 @ 在我服务器的 Java 项目中?我的服务器需要哪个keys/secrets来解密/验证idToken JWT的第三部分?谢谢!! -
我没有经验来帮助解决其他问题。最好提出一个新问题。
-
我already have,您实际上回答了我列出的其中一个问题,因此我在这里抓住机会。无论如何谢谢。 :)
标签: java android firebase google-api firebase-authentication