我已经关注了Firebase的介绍,但我的build.gradle
似乎有问题。
主活动代码
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user !=null){
// user is signed in
}else {
//user is signed out
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(Arrays.asList(
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build(),
new AuthUI.IdpConfig.GitHubBuilder().build(),
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build()))
.build(),
RC_SIGN_IN);
}
}
代码 构建.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:26.0.+'
//24.2.0
compile 'com.android.support:appcompat-v7:26.0.+'
//v7:24.2.+
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
//FireBase Dependency
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
// 27.0.3
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
defaultConfig {
// ...
resConfigs "en" // And any other languages you support
}
implementation 'com.google.firebase:firebase-core:16.0.1'
compile 'com.google.firebase:firebase-database:16.0.1'
compile 'com.google.firebase:firebase-auth:16.0.1'
compile 'com.google.android.gms:play-services-auth:15.0.1'
compile 'com.google.firebase:firebase-firestore:17.0.1'
compile 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
}
我已经使缓存失效并重新启动了几次,但这似乎没有帮助。 我是否错过了其他依赖项?
你好,我相信你需要包括
import com.firebase.ui.auth.AuthUI;
在您的主活动文件中