A valid Facebook app id must be set in the AndroidManifest.xml
Add below in build.gradle(Module:app) file:
repositories {
mavenCentral()
}
and
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
now add below in AndroidManifest.xml file :
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
add following in activity_main.xml file :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.demonuts.fblogin.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/text"/>
<com.facebook.login.widget.LoginButton
android:id="@+id/btnfb"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
The meta-data in my case were located out of the application scope. Normally, it should be located in your manifest like this:
<application>
...
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
</application>