[英]I am using firebase UI login into my app but when i use Facebook builder it stops the app how to inflate that button..?
i am enclosing the code of the Java file, dependency file and Manifestfile我附上了 Java 文件、依赖文件和清单文件的代码
i declared outside我在外面宣布
private static final int MY_REQUEST_CODE = 123;
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build());
after this i mentioned this在这之后我提到了这个
Intent intent = AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.setLogo(R.drawable.logo)
.setTheme(R.style.LoginTheme)
.setTosAndPrivacyPolicyUrls(
"https://example.com/terms.html",
"https://example.com/privacy.html")
.build();
and the last i mention the startActivity最后我提到了 startActivity
startActivityForResult(intent,MY_REQUEST_CODE);
now this is my Dependencies File现在这是我的依赖文件
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0' //1.0.2
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
//Facebook
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.facebook.android:facebook-android-sdk:5.15.1'
implementation 'com.google.android.gms:play-services-auth:18.0.0'
implementation 'com.google.firebase:firebase-auth:19.3.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//Cardview and Material
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0' //1.1.0
//button
implementation 'info.hoang8f:fbutton:1.0.5'
implementation 'com.google.android.gms:play-services-location:17.0.0'
}
after this it is my Manifest file在此之后这是我的清单文件
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<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=".Geo_Activity"/>
<activity android:name=".Profile" />
<activity android:name=".HomeActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId"
tools:replace="android:value"
android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
now the problem is that when I add the Facebuilder().build() line into my array list the app is crashed现在的问题是,当我将 Facebuilder().build() 行添加到我的数组列表中时,应用程序崩溃了
Change your dependencies to:将您的依赖项更改为:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0' //1.0.2
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.firebaseui:firebase-ui-auth:6.2.1'
//Facebook
implementation 'com.facebook.android:facebook-android-sdk:5.15.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//Cardview and Material
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0' //1.1.0
//button
implementation 'info.hoang8f:fbutton:1.0.5'
implementation 'com.google.android.gms:play-services-location:17.0.0'
Edit:编辑:
Add these two strng resources to your strngs:将这两个字符串资源添加到您的字符串中:
<string name="facebook_application_id" translatable="false">APP_ID</string>
<!-- Facebook Application ID, prefixed by 'fb'. Enables Chrome Custom tabs. -->
<string name="facebook_login_protocol_scheme" translatable="false">fbAPP_ID</string>
If you run the app, It will work now, but clicking the facebook button won't get the user authenticated until you get the app id and scheme如果您运行该应用程序,它现在可以工作,但单击 facebook 按钮不会让用户获得身份验证,直到您获得应用程序 ID 和方案
To get the app id, log into your facebook account, visit the developers page https://developers.facebook.com/ Create an app there, then add the 'facebook login' and then follow the instructions given.要获取应用程序 ID,请登录您的 facebook 帐户,访问开发人员页面https://developers.facebook.com/然后按照给出的说明添加并创建应用程序。 You will find your app id in the top of the page of your facebook app
您将在 facebook 应用程序的页面顶部找到您的应用程序 ID
Just two notes:只需两个注意事项:
You need copy the 'OAuth Redirect URI' from the firebase console page(the link given when enabling facebook authentication) to the settings of your facebook app您需要将“OAuth Redirect URI”从 firebase 控制台页面(启用 facebook 身份验证时给出的链接)复制到 Z26CAE7718C32180A7A0F8E19D6D40A5 的设置中
You will need the 'Key hash' which you can be obtained as described here https://stackoverflow.com/a/25524657/9006761 You will then copy it to your facebook app settings您将需要“密钥哈希”,您可以按照此处的说明获取该密钥https://stackoverflow.com/a/25524657/9006761然后将其复制到您的 facebook 应用程序设置
Edit: Scheme is just app id prefixed by 'fb'编辑:方案只是以'fb'为前缀的应用程序ID
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.