Java 我正在使用firebase UI登录我的应用程序,但当我使用Facebook builder时,它会停止应用程序。如何将该按钮充气。。?
我附上了Java文件、依赖文件和Manifestfile的代码 我在外面宣布Java 我正在使用firebase UI登录我的应用程序,但当我使用Facebook builder时,它会停止应用程序。如何将该按钮充气。。?,java,android,firebaseui,Java,Android,Firebaseui,我附上了Java文件、依赖文件和Manifestfile的代码 我在外面宣布 private static final int MY_REQUEST_CODE = 123; List<AuthUI.IdpConfig> providers = Arrays.asList( new AuthUI.IdpConfig.PhoneBuilder().build(), new AuthUI.IdpConfig.FacebookBuil
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());
最后我提到了星际触觉
startActivityForResult(intent,MY_REQUEST_CODE);
现在这是我的依赖项文件
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'
}
这之后是我的清单文件
<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>
将依赖项更改为:
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'
编辑:
将这两个strng资源添加到您的strng:
<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>
APP\u ID
fbAPP_ID
如果你运行该应用程序,它现在就可以工作了,但在你获得应用程序id和方案之前,单击facebook按钮将无法对用户进行身份验证
要获取应用程序id,请登录您的facebook帐户,访问开发者页面
在那里创建一个应用程序,然后添加“facebook登录”,然后按照给出的说明操作。你将在facebook应用程序页面顶部找到你的应用程序id
只有两个注释:
- 您需要将“OAuth重定向URI”从firebase控制台页面(启用facebook身份验证时提供的链接)复制到facebook应用程序的设置中
- 您将需要“密钥散列”,您可以按此处所述获得该散列
然后,您将其复制到您的facebook应用程序设置中
编辑:
Scheme只是以“fb”为前缀的应用程序id你能包含崩溃错误声明吗?我得到了这个错误………..>>>java.lang.RuntimeException:无法实例化活动组件信息{com.example.demotask/com.example.demotask.MainActivity}:java.lang.IllegalStateException:Facebook提供程序未配置。确保添加facebook\u应用程序\u id
字符串。查看文档了解更多信息:加油,伙计!你为什么不早点发布呢?!!我将编辑答案抱歉,请原谅我将字符串添加到strings.xml中,并将Oauth添加到facebook设置中,但这里的look文档同样不起作用
<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>