2017-10-17 184 views
0

我想在我的應用程序中添加FirebaseUI身份驗證,但我很困擾它。我在我的應用中添加了Facebook,Twitter和電話號碼驗證,但它給了我錯誤:Cannot resolve method setAvailableProvidersCannot resolve symbol IdpConfig。我應該怎樣做才能解決這個錯誤?你可以在圖像中看到我有錯誤和紅線。無法解析方法setAvailableProviders和無法解析符號IdpConfig

這裏是我的manifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.anonymous.userlogin"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:roundIcon="@mipmap/ic_launcher_round" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity android:name=".MainActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
    <uses-permission android:name="android.permission.INTERNET"/> 

</manifest> 

這裏是我的gradle這個文件

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 

    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     maven { url 'https://maven.fabric.io/public' } 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

這裏是我的gradle這個文件:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.2" 
    defaultConfig { 
     applicationId "com.example.anonymous.userlogin" 
     minSdkVersion 16 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    //compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    //android authentication dependicies. 
    compile 'com.google.firebase:firebase-auth:10.0.1' 
    //android login with fb tw ph user nterface dependices 

    compile 'com.firebaseui:firebase-ui-auth:0.6.0' 
    //compile 'com.firebaseui:firebase-ui-auth:3.0.0' 
    //facebook dependicies 
    compile 'com.facebook.android:facebook-login:4.27.0' 
    //twitter dependicies 
    compile("com.twitter.sdk.android:twitter-core:[email protected]") { transitive = true } 
    testCompile 'junit:junit:4.12' 
} 


apply plugin: 'com.google.gms.google-services' 

configurations.all { 
    resolutionStrategy.eachDependency { DependencyResolveDetails details -> 
     def requested = details.requested 
     if (requested.group == 'com.android.support') { 
      if (!requested.name.startsWith("multidex")) { 
       details.useVersion '26.0.0-alpha1' 
      } 
     } 
    } 
} 

這裏是我的主要的代碼活動

package com.example.anonymous.userlogin; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import com.firebase.ui.auth.AuthUI; 
import com.google.firebase.auth.FirebaseAuth; 
import java.util.Arrays; 
public class MainActivity extends AppCompatActivity { 
    private static final int RC_SIGN_IN = 123; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     FirebaseAuth auth = FirebaseAuth.getInstance(); 
     if (auth.getCurrentUser() != null) 
      {} 
     else 
      { 
      // not signed in 
       startActivityForResult(
         AuthUI.getInstance() 
           .createSignInIntentBuilder() 
           .setAvailableProviders(
             Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(), 
               new AuthUI.IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build(), 
               new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(), 
               new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build(), 
               new AuthUI.IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build())) 
           .build(), 
         RC_SIGN_IN); 




      } 
    } 
} 

這裏的標記錯誤的截圖:

enter image description here

回答

0

您正在使用FirebaseUI驗證(com.firebaseui:firebase-ui-auth)版本0.6.0不具備此功能。您應該使用2.x或3.x版本。

在您的應用程序的build.gradle文件更改此:

compile 'com.firebaseui:firebase-ui-auth:0.6.0' 
//compile 'com.firebaseui:firebase-ui-auth:3.0.0' 

要這樣:

compile 'com.firebaseui:firebase-ui-auth:3.0.0'