Simplified Coding

  • About
  • Contact Us
  • Advertise
  • Privacy Policy
You are here: Home / Android Application Development / Android Advance / Login With Facebook Android Studio using Facebook SDK 4

Login With Facebook Android Studio using Facebook SDK 4

May 4, 2015 by Belal Khan 111 Comments

Hello friends, welcome to our new tutorial. In this tutorial we will create a login with facebook android app using android studio and facebook sdk 4.0. So lets begin.

Creating Android Project

  • Open Android Studio and Click on File-> New ->New Project
  • Give your application a name (in my case it is AndroidLogin) and a package (mine is net.simplifiedcoding)
  • Select Phone or Tablet
  • Select Blank Activity with Fragment.
  • Leave the rest things as it is and finish.
  • Now once our project is ready we need to configure a lot of things so lets begin.

Prerequisites for creating Login with Facebook Android App

  • Facebook app configured and linked to our android app
  • Facebook SDK
  • Facebook App ID
  • Android Key Hash
  • Facebook Activity

Lets start with creating Facebook App

Configuring Facebook SDK to Android Studio

  • Go to your gradle scripts -> build.gradle(Module:app)
  • Add the following code

Gradle Scripts
1
2
3
    repositories {
        mavenCentral()
    }

  • Now add a new dependency for Facebook SDK
  • Inside dependencies add this line

Gradle Scripts
1
compile 'com.facebook.android:facebook-android-sdk:4.0.0'

  • It will download facebook sdk and will take some time. It can take long time if you have a slow internet connection. So mean while lets create our facebook app.

Creating Facebook App

  • Go to https://developers.facebook.com/. If you have not registered yourself as a developer yet then facebook will ask you to register as a developer. Simply register as a developer. (Congrats you are now a developer :P)
  • From the top navigation menu hover over my apps.
  • Then click add a new app.
  • You will asked to select a platform, click on android.
  • On the new page you can select quick start or you can select skip and create app id from the upper right corner.
  • Click on skip and create app id.
  • Give a display name and a namespace for your app as shown in the image below.
login with facebook android

Creating Facebook App ID

  • Click create app id.
  • You will be redirected to your apps dashboard.
login with facebook android

Apps Dashboard

  • Here you can get your app id. Copy the app id it will be used further. (I have made my app id hidden because i cant let you see it for security reasons)
  • Now from the left click on settings.
  • Click on add a platform and select android.
  • Enter your package name and class name of your main activity and click on save changes
  • The last thing you need is your App Key Hashes.

 

login with facebook android

Adding a Platform for your App

Generating Key Hashes for your Login With Facebook Android App

  • Go to android studio.
  • On your project open your strings.xml file  (res->values->strings.xml)
  • Add the below code

1
<string name="app_id">YOUR APP ID</string>

  • Replace your actual app id with your app id.
  • Now go to your AndroidManifest.xml
  • First add internet permission using the following code

AndroidManifest.xml
1
    <uses-permission android:name="android.permission.INTERNET"/>

  • Add a this meta-data code inside your application

AndroidManifest.xml
1
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>

  • This is containing our app id which we defined inside strings.xml.
  • Now create a new class in your package and name it MyApplication (name doesn’t matter you can name it anything)
  • Copy the following code

MyApplication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package net.simplifiedcoding.androidlogin;
 
import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;
 
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
 
/**
* Created by Belal on 5/3/2015.
*/
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        printHashKey();
    }
 
    public void printHashKey(){
        // Add code to print out the key hash
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "net.simplifiedcoding.androidlogin",
                    PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        } catch (PackageManager.NameNotFoundException e) {
 
        } catch (NoSuchAlgorithmException e) {
 
        }
    }
}

  • Make sure in the above code your provide your application’s package name.
  • The above class will print the KeyHash in the logcat. But we still need to define this class inside your AndroidManifest.
  • Go to AndroidManifest.xml again and Inside application opening tag define your class as shown below

AndroidManifest.xml
1
2
3
4
5
6
7
8
9
10
11
    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
        .
        .
        .
    </application>

  • Now execute your app and you will get your keyhash in your logcat.
  • Copy the keyhash and enter that to your app settings in facebook and click save.

Creating your Login With Facebook Android App

  • For facebook login Facebook SDK provides an activity that will open while login. You only need to add that activity to your manifest file.
  • Add the facebook activity using the following code.

Facebook Activity
1
2
3
4
5
      <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" />

  • So your final AndroidManifest.xml would be like

AndroidManifest.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.simplifiedcoding.androidlogin" >
 
    <uses-permission android:name="android.permission.INTERNET"/>
 
    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <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" />
    </application>
 
</manifest>

  • Now come to your fragment layout and create a TextView and a Facebook Login Button. The button is provided by facebook sdk. You can use the below code.

fragment_main.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:orientation="vertical"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivityFragment">
 
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/textView"
        android:layout_centerHorizontal="true"/>
 
    <com.facebook.login.widget.LoginButton
        android:id="@+id/login_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
 
</LinearLayout>

  • We will show the user name in the textview after successful login.
  • Go to your MainFragment.java and copy the following code.

MainFragment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package net.simplifiedcoding.androidlogin;
 
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
 
import com.facebook.AccessToken;
import com.facebook.AccessTokenTracker;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.Profile;
import com.facebook.ProfileTracker;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
 
 
/**
* A placeholder fragment containing a simple view.
*/
public class MainFragment extends Fragment {
 
    private CallbackManager callbackManager;
    private TextView textView;
 
    private AccessTokenTracker accessTokenTracker;
    private ProfileTracker profileTracker;
 
    private FacebookCallback<LoginResult> callback = new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            AccessToken accessToken = loginResult.getAccessToken();
            Profile profile = Profile.getCurrentProfile();
            displayMessage(profile);
        }
 
        @Override
        public void onCancel() {
 
        }
 
        @Override
        public void onError(FacebookException e) {
 
        }
    };
 
    public MainFragment() {
 
    }
 
 
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
 
        callbackManager = CallbackManager.Factory.create();
 
        accessTokenTracker= new AccessTokenTracker() {
            @Override
            protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) {
 
            }
        };
 
        profileTracker = new ProfileTracker() {
            @Override
            protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) {
                displayMessage(newProfile);
            }
        };
 
        accessTokenTracker.startTracking();
        profileTracker.startTracking();
    }
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_main, container, false);
    }
 
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        LoginButton loginButton = (LoginButton) view.findViewById(R.id.login_button);
        textView = (TextView) view.findViewById(R.id.textView);
 
        loginButton.setReadPermissions("user_friends");
        loginButton.setFragment(this);
        loginButton.registerCallback(callbackManager, callback);
 
    }
 
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
 
    }
 
    private void displayMessage(Profile profile){
        if(profile != null){
            textView.setText(profile.getName());
        }
    }
 
    @Override
    public void onStop() {
        super.onStop();
        accessTokenTracker.stopTracking();
        profileTracker.stopTracking();
    }
 
    @Override
    public void onResume() {
        super.onResume();
        Profile profile = Profile.getCurrentProfile();
        displayMessage(profile);
    }
}

  • Run your app now and Bravo it works 😉
  • If you are having troubles then you can download the source code of this project from here

[download id=”1392″] 

Some more android tutorials you should check 

  • Twitter Login Android Studio
  • Login with Google Android Studio

So thats all for this login with facebook android app tutorial friends. Feel free to ask if you have any queries or troubles following the steps. Thank you 🙂

Sharing is Caring:

  • Tweet
  • Share on Tumblr
  • More
  • Pocket
  • Print
  • Email

Related

Filed Under: Android Advance, Android Application Development Tagged With: android facebook login sample, facebook android sdk tutorial, facebook login sdk, log in facebook android

About Belal Khan

I am Belal Khan, I am currently pursuing my MCA. In this blog I write tutorials and articles related to coding, app development, android etc.

Comments

  1. Hugo Ramos says

    May 8, 2015 at 10:26 pm

    When i create a Blank Activity with Fragment it creates me an activity that extends from ActionBarActivity and then creates a class that extends from Fragment, how can i execute my MainFragment from an class that extends form ActionBarActivity.

    Reply
    • Belal Khan says

      May 9, 2015 at 6:52 am

      I am not getting what you want to ask? Tell me your actual requirement.. or you can check details about fragments from here – > http://developer.android.com/training/basics/fragments/creating.html

      Reply
      • jimmy says

        April 18, 2017 at 9:58 am

        hey bilal khan …can you make an tutorial on sharing photos videos or status from android app to facebook automatically…

        Reply
    • geetha says

      October 20, 2016 at 9:13 am

      from your activity you can go to mainfragment, after setcontentview paste this

      if (savedInstanceState == null){
      getSupportFragmentManager().beginTransaction()
      .add(android.R.id.content, new MainFragment ()).commit();}

      Reply
  2. Foad Shariat says

    May 15, 2015 at 9:37 am

    Your tutorial is great and helped me a lot but I want to create the login button on a popup window, how should I do that? and how can I hide the login button when the user has already loged in? and will you do some tutorials on facebook sharing and like button too?

    Reply
    • Belal Khan says

      May 16, 2015 at 5:00 am

      Ok stay tuned I will try to help you with some more tutorials ASAP 🙂

      Reply
  3. Sunny says

    June 17, 2015 at 5:24 pm

    Is there a way to use the FB SDK log in button without using a fragment? Can I just put it straight on the MainActivity? If so, how do I do this?

    Reply
    • Belal Khan says

      June 18, 2015 at 4:41 am

      Yeah you can obviously do that

      Reply
      • Tushar Mehta says

        March 8, 2016 at 10:59 am

        How can i integrate this code in my main activity without creating a fragment class??

        Reply
        • pavithra says

          November 28, 2016 at 10:01 am

          //refer the link
          http://www.androidwarriors.com/2016/02/facebook-integration-in-android-studio.html

          Reply
      • Tushar Mehta says

        March 8, 2016 at 11:03 am

        Please tel me the way to do this without creating main fragment…..

        Reply
  4. Michel says

    June 18, 2015 at 5:16 pm

    I downloaded the code, but it is a game. Please, could you check the link?

    Reply
    • Belal Khan says

      June 19, 2015 at 5:02 am

      Sorry for the inconvenience I corrected the link you can check it now… 🙂

      Reply
      • Valentin says

        March 26, 2016 at 5:55 pm

        Hai, i have a problem, when i connect in my account its work, but in the second part it say the my hash key is not stored, what does it mean, i use your applciation. Thanks for your help

        Reply
  5. Asheesh says

    June 20, 2015 at 5:33 pm

    Thanks man! I got your site after one week and you wont believe even after trying millions of options it dint work. Amazing work 😀

    Reply
    • Belal Khan says

      June 22, 2015 at 4:34 am

      You welcome bro 🙂

      Reply
  6. Muhammad Sohail says

    June 23, 2015 at 6:26 am

    I try this code butt my application not open just an error message shown “Your application is forcefully stoped”

    Reply
    • Belal Khan says

      June 23, 2015 at 2:45 pm

      In my case it is working absolutely fine as you can see on the video. Send me your code.. I will check it

      Reply
      • saiyam says

        November 16, 2015 at 6:27 am

        mine also same problem 🙁

        Reply
        • Belal Khan says

          November 16, 2015 at 7:23 am

          Check what exception your app is throwing from your logcat

          Reply
          • LUIS says

            January 23, 2016 at 7:54 pm

            hi bro, i have the same problem, can you help me???
            can i send you my code to you see it?

            if you say yes, where and how i can send you this??

  7. Vaskar Paul says

    June 26, 2015 at 6:57 am

    I need to get the email id, phone number , password of the after login. please suggest how to get that. Thanks i advance.

    Reply
    • Belal Khan says

      June 27, 2015 at 4:34 am

      List permissions = new ArrayList();
      permissions.add(“email”);

      Add all the permissions you need and then
      loginButton.setReadPermissions(permissions);

      For more information you can check the sdk docs from here https://developers.facebook.com/docs/facebook-login/android/permissions

      Reply
  8. Diego Abel says

    July 9, 2015 at 6:36 pm

    Thanks a lot! work 100%.. How I can start another activity after login ? And how can I pass the parameters of facebook to the new activity?

    Reply
  9. sabina joshi says

    July 12, 2015 at 12:11 pm

    how can I start new activity after successful login?

    Reply
    • Belal Khan says

      July 12, 2015 at 12:27 pm

      You can use Intent to start another activity..

      Reply
      • Christian says

        October 3, 2015 at 4:23 am

        How?

        Reply
  10. Terrel says

    July 13, 2015 at 4:29 pm

    Hi, great tutorial but i seem to have an error through your code. when i run inspect code in android studio it comes up with an error such as…

    Location     
     class anonymous in FacebookCallback callback (mobliedevelopment.terrelsimeongordon.hwl_fb.MainFragment)  

     Problem synopsis     
     Variable ‘accessToken’ at line 38 is never used

    i downloaded the source code yet the same error comes up

    this is the code that android is complaining about?

    private FacebookCallback callback = new FacebookCallback() {
    @Override
    public void onSuccess(LoginResult loginResult) {
    AccessToken accessToken = loginResult.getAccessToken();
    Profile profile = Profile.getCurrentProfile();
    displayMessage(profile);
    }

    do you have any clue why it is not working and why it can not find accessToken? grateful if you could help answer this 1 million dollar question 🙂

    Reply
    • Terrel says

      July 13, 2015 at 4:48 pm

      Hi sorry about that i just found the issue 🙂
      just wondering if its possible to extend just an activity instead of an ActionBarActivity for the MainActivity? if so how would you i go about altering this code to that requirement?

      Reply
  11. sagar devanga says

    July 16, 2015 at 3:43 pm

    How do i change the height and width of the Login button ( com.facebook.login.widget.LoginButton ) i m using the 4.1 sdk for facebook

    Reply
    • Belal Khan says

      July 18, 2015 at 3:26 pm

      you can also create your own button 🙂

      Reply
  12. Nilesh Yerunkar says

    July 19, 2015 at 2:22 pm

    thanks bro.
    its really useful article.

    Reply
  13. Akshay Shah says

    July 27, 2015 at 6:59 am

    I need to get email Id of the user, added the permission of it too but How do i print that in the TextView. Profile.getEmailID(); doesn’t work. Please help

    Reply
    • Amol Chavhan says

      October 18, 2015 at 3:15 pm

      did you find any solution ?

      Reply
  14. vivek says

    August 18, 2015 at 10:16 am

    i m not getting the friend list

    Reply
  15. sumit says

    August 18, 2015 at 10:18 am

    i need the friend list of my friends but i m not.
    plz tell me the permissions to write for it how can we aceess all that ..
    i am new in android

    Reply
  16. Rohitrathore says

    August 21, 2015 at 10:31 am

    The problem is how to call another activity right after authorization succeed and remove logout button.

    thanks in advance……

    Reply
  17. raji says

    September 11, 2015 at 8:21 am

    help me to print complete profile information of the user.
    Thank you

    Reply
    • raji says

      September 11, 2015 at 8:31 am

      Session and graph is not working in this sdk version. so please give the code to get the complete profile information.

      your tutorial heiped me to get the username from profile using profile.getName();

      similarly i need to get the all profile information. please give the code.

      Thanks in advance

      Reply
      • Belal Khan says

        September 11, 2015 at 12:40 pm

        ok stay tuned and I will try to post a new tutorial for this

        Reply
  18. rohan says

    September 12, 2015 at 8:33 am

    login page of facebook appeared only once during the first run. Subsequent running doesnt show it.Please help me.
    also during debugging, variable profile gets null value. iam a beginner to android. please help

    Thanks

    Reply
  19. arpit says

    September 16, 2015 at 11:27 am

    getting error in logcat please sir help me

    Error:A problem occurred configuring project ‘:app’.
    > Could not download facebook-android-sdk.aar (com.facebook.android:facebook-android-sdk:4.0.0)
    > Could not get resource ‘https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/4.0.0/facebook-android-sdk-4.0.0.aar’.
    > Could not GET ‘https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/4.0.0/facebook-android-sdk-4.0.0.aar’.
    > d29vzk4ow07wi7.cloudfront.net

    Reply
  20. Bala says

    September 28, 2015 at 4:09 am

    Hi,

    I am able to integrate facebook login into my app successfully by follwing your post. The actual req of my app is to trigger facebook status at the end of every month. When i try to login after two months login dialog does not open up. It throws a FacebookAuthorizationException. Can you please help me in figuring it out.

    Note: I believe due to access token expiry facebook login dialog does not open. You can check it

    Thanks.

    Reply
  21. Raj says

    September 29, 2015 at 8:06 pm

    After clicking the Facebook login button, I am getting an error saying you are not logged in. please log in and try again…how to login?

    Reply
  22. dipali says

    October 16, 2015 at 10:34 am

    10-16 15:59:05.620 1304-1335/? E/InputDispatcher﹕ channel ‘c10b4fa com.example.dipali.androidlogin/com.example.dipali.androidlogin.MainActivity (server)’ ~ Channel is unrecoverably broken and will be disposed!

    I have this error.How can i solve this error?

    Reply
    • Belal Khan says

      October 16, 2015 at 12:51 pm

      Try downloading my source code and check you are still getting the error or not?

      Reply
  23. dipali says

    October 17, 2015 at 5:45 am

    I referred your source code Still i am having this error.Process

    Reply
  24. dipali says

    October 17, 2015 at 5:47 am

    Couldn’t load memtrack module (No such file or directory)
    10-17 11:11:42.089 2347-2347/? E/android.os.Debug﹕ failed to load memtrack module: -2
    10-17 11:11:49.677 1837-1837/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
    10-17 11:11:49.677 1837-1837/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn’t include a PendingIntent in the extras?
    10-17 11:11:50.245 2384-2384/? E/memtrack﹕ Couldn’t load memtrack module (No such file or directory)
    10-17 11:11:50.246 2384-2384/? E/android.os.Debug﹕ failed to load memtrack module: -2
    10-17 11:11:50.345 2384-2392/? E/art﹕ Thread attaching while runtime is shutting down: Binder_1
    10-17 11:11:53.054 1837-1837/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
    10-17 11:11:53.055 1837-1837/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn’t include a PendingIntent in the extras?
    10-17 11:11:59.472 2393-2393/? E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
    10-17 11:11:59.956 2393-2393/? E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
    10-17 11:11:59.956 2393-2393/? E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
    10-17 11:11:59.956 2393-2393/? E/chromium﹕ [ERROR:gl_surface_egl.cc(327)] No suitable EGL configs found.
    10-17 11:11:59.956 2393-2393/? E/chromium﹕ [ERROR:gl_surface_android.cc(23)] GLSurfaceEGL::InitializeOneOff failed.
    10-17 11:11:59.956 2393-2393/? E/chromium﹕ [ERROR:browser_main_loop.cc(698)] GLSurface::InitializeOneOff failed
    10-17 11:12:00.266 2393-2393/? E/DataReductionProxySettingListener﹕ No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
    10-17 11:12:00.913 953-953/? E/SELinux﹕ avc: denied { find } for service=batteryproperties scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:healthd_service:s0 tclass=service_manager
    10-17 11:12:04.515 2393-2474/? A/chromium﹕ [FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
    ——— beginning of crash
    10-17 11:12:04.515 2393-2474/? A/libc﹕ Fatal signal 6 (SIGABRT), code -6 in tid 2474 (GpuThread)
    10-17 11:12:04.634 962-962/? A/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    10-17 11:12:04.634 962-962/? A/DEBUG﹕ Build fingerprint: ‘generic_x86/sdk_google_phone_x86/generic_x86:6.0/MRA44C/2166767:eng/test-keys’
    10-17 11:12:04.634 962-962/? A/DEBUG﹕ Revision: ‘0’
    10-17 11:12:04.634 962-962/? A/DEBUG﹕ ABI: ‘x86’
    10-17 11:12:04.634 962-962/? A/DEBUG﹕ pid: 2393, tid: 2474, name: GpuThread >>> com.example.dipali.androidlogin <<>> com.example.dipali.androidlogin <<<
    10-17 11:15:52.846 962-962/? A/DEBUG﹕ signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr ——–
    10-17 11:15:52.851 962-962/? A/DEBUG﹕ Abort message: '[FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
    '
    10-17 11:15:52.851 962-962/? A/DEBUG﹕ eax 00000000 ebx 000009b2 ecx 00000a05 edx 00000006
    10-17 11:15:52.851 962-962/? A/DEBUG﹕ esi a04bf980 edi 00000000
    10-17 11:15:52.851 962-962/? A/DEBUG﹕ xcs 00000073 xds 0000007b xes 0000007b xfs 000000c7 xss 0000007b
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ eip b73b55d6 ebp 00000a05 esp a04bec40 flags 00200206
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ backtrace:
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ #00 pc 000845d6 /system/lib/libc.so (tgkill+22)
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ #01 pc 00081618 /system/lib/libc.so (pthread_kill+70)
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ #02 pc 00027205 /system/lib/libc.so (raise+36)
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ #03 pc 000209e4 /system/lib/libc.so (abort+80)
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ #04 pc 0037328a /system/app/webview/webview.apk
    10-17 11:15:52.852 962-962/? A/DEBUG﹕ #05 pc 000009a3 /data/misc/shared_relro/libwebviewchromium32.relro
    10-17 11:15:53.423 962-962/? A/DEBUG﹕ Tombstone written to: /data/tombstones/tombstone_03
    10-17 11:15:53.423 962-962/? E/DEBUG﹕ AM write failed: Broken pipe
    10-17 11:15:56.910 954-954/? E/libEGL﹕ called unimplemented OpenGL ES API
    10-17 11:15:56.911 954-954/? E/SurfaceFlinger﹕ glCheckFramebufferStatusOES error -2129925904
    10-17 11:15:56.911 954-954/? E/SurfaceFlinger﹕ got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot

    Reply
  25. sivanesan says

    October 17, 2015 at 8:33 am

    Hi, that was an really awesome tutorial, I run the app, go the output. But I tried to reopen means its shows the HashKey error. Please guide me

    Reply
    • Belal Khan says

      October 18, 2015 at 7:16 am

      Check you have generated the HashKey correctly or not?

      Reply
  26. Clifford Galarpe says

    October 18, 2015 at 12:20 am

    How can i dentify the keyhash on the logcat ? :/

    Reply
    • Belal Khan says

      October 18, 2015 at 7:17 am

      follow the post carefully.. and after writing the keyhash part run you app and check the logcat for keyhash

      Reply
  27. pradeep says

    October 19, 2015 at 2:50 pm

    Hi Belal u have done a good job. I tried many totorials but got disappointed. i used your tutorial in my case it is working, but if i try to login second time it shows the message “This app has no Android key hashes configured. pls configure hash key. but i configured key hash succesfully still get error msg from second time login.. pls help me..

    Reply
  28. Raj Roshan says

    October 19, 2015 at 3:24 pm

    I am making one movie review app, and I tried to create a login with facebook button at my login page.
    When I start my app for 1st time, then it works fine, get logged in from Facebook, and also able to display name.
    But after the 1st time when I log out from it, and try to log in again, then it always shows ” The app has no Android key hashes configured. Configure your app key hashes at …………”
    Please guide me and help me with solution to it. Please as I have to submit it as a project day after tomorrow. please

    Reply
  29. vikram says

    October 28, 2015 at 9:37 am

    i have issue when i created facebook app id then :

    There was a problem verifying the package name com.example.vicky.facelogin on Google Play. Please check the package name and try again.
    If your app isn’t listed publicly on Google Play yet you can ignore this message

    please help me

    Reply
    • Belal Khan says

      October 28, 2015 at 3:01 pm

      You can ignore this message.. or you can try creating a new project with different package name

      Reply
  30. Rishabh says

    November 3, 2015 at 4:44 pm

    Hi belal, awesome tut! 🙂
    i am not getting my KEY HASH on log cat 🙁 and tried it by using openSsl also bt it is also not working.. can you please help me.. 🙁

    Reply
    • Moin Khan says

      December 8, 2015 at 4:05 pm

      Hi Belal,
      I have tried your code and it’s working as i want but i have one question that now i want to save user data who login with facebook at mysql database. I have POST Json API but not getting anything after spending hours on google. Can anyone help me ?

      Reply
      • anruag says

        January 5, 2016 at 5:51 am

        same problem with me please help anyone.

        Reply
  31. Nitin says

    November 27, 2015 at 7:31 pm

    Great Tutorial !!!!!, Thanks

    Reply
  32. Moin Khan says

    December 4, 2015 at 5:30 am

    Hi Bilal,
    Thank you for this great tutorial. I just want to share one solution for those who’s getting error of hash key. When you run your programme at first time it’s successfully login but second time it give error of hash key. The solution is the key which is shown in device as a error is your correct hash key so save this key on facebook app setting and the error is gone. thanks

    Reply
  33. Ajay says

    December 5, 2015 at 9:56 am

    Bro..It’s getting Unfortunately Error,

    Reply
    • Akash says

      December 16, 2015 at 6:54 am

      yes me too and when corrected it says hello world only

      Reply
  34. Ganesh says

    December 6, 2015 at 4:17 am

    Hi thanks for this tutorial. I successfully created and executed the app.
    But i want to get facebook friends list. I saw the documentation and it was little bit confusing. How to proceed , please help. Thanks in advance.

    Reply
  35. Parth Vora says

    December 7, 2015 at 12:26 pm

    Hello there, i have seen this tutorial and it is very useful to me, but i have one question. How can i create a login activity with facebook in it? Means that there is simple login button and i don’t want to use fragment for it. So how to do this, can you explain or give me some idea to do it. Thanks for help!!!

    Reply
  36. Ekta Bhawsar says

    December 11, 2015 at 9:52 am

    I got a FacebookException i.e. couldn’t connect to the server, after click on login button and comes progress bar.
    please reply, thanks in advance.

    Reply
  37. Nikhil says

    December 11, 2015 at 10:04 pm

    how to get the phone number from facebook

    Reply
  38. Akash says

    December 16, 2015 at 6:42 am

    I tried your code, but it appear only with mainactivity saying hello world, there is no button. I checked code and found other class is not related with mainactivity. Please check the Link given below for complete code

    https://www.dropbox.com/sh/x68jby50q8rq6kh/AACRIDh3h2VCrNlLoRkBWsPVa?dl=0

    Reply
    • Akash says

      December 16, 2015 at 7:07 am

      I got the answer just Implement a fragment in main activity and call main fragment thankyou

      Reply
  39. Mamtha Gowda says

    December 22, 2015 at 5:06 am

    Hai

    After login i want to fetch the user email id and mobile number.
    if u have any materials please share me.

    Thank you.

    Reply
  40. Urmil Malhotra says

    January 4, 2016 at 11:42 am

    Log in attempt failed: LoginActivity could not be started
    at com.facebook.login.LoginManager.startLogin(LoginManager.java:382)

    i have run app then above error show

    if (!started) {
    FacebookException exception = new FacebookException(
    “Log in attempt failed: LoginActivity could not be started”);
    logCompleteLogin(LoginClient.Result.Code.ERROR, null, exception);
    this.pendingLoginRequest = null;
    throw exception;
    }
    this is line no 382 place say how can start the LoginActivity??

    Reply
  41. Arpit Patel says

    January 4, 2016 at 3:46 pm

    Appreciate your work but i need user email address and phone number How can i get this ?

    Reply
  42. anruag says

    January 5, 2016 at 5:49 am

    hey belal,

    I want to save user data ( user name and email id) to my data base, how to make it. and thanks for grt tuts.

    Reply
  43. sahil says

    January 7, 2016 at 9:39 am

    How i create icon to Option menu string

    Reply
  44. Luis says

    January 23, 2016 at 7:47 pm

    hi man!… I emerged a mistake is that when runing the app does not open the LAYOUT where is the option to sign, that is only the MAIN ACTIVITY where i get nothing. I hope you can help me

    Reply
  45. honey says

    February 3, 2016 at 12:13 pm

    how cam ve get the emailid after login or whow can we fetch the email id in facebook

    Reply
  46. Gladwin says

    February 22, 2016 at 3:53 am

    How to call a fregment from activity

    Reply
  47. Manoj says

    February 29, 2016 at 7:17 am

    hi i copied the code but iam not getting image when iam logged in.. Can you give me the code for that how to get the user image when logged into app..

    Reply
  48. Thanesh says

    March 7, 2016 at 1:32 pm

    what about the main activity
    ?

    Reply
  49. lovkesh sharma says

    March 8, 2016 at 11:07 am

    How can we use this code without using MainFragment?….reply fast

    Reply
  50. aakriti says

    March 11, 2016 at 11:11 am

    Cant find Hash Key ..Please helpppp

    Reply
    • Pal says

      June 17, 2016 at 8:40 pm

      Hey aakriti….just change your logcat from verbose to debug…
      and then in search area wite key hash….you will get it (hash key) in logcat…
      Hope this will help u or anybody else 🙂

      Reply
  51. Sumit Kaushik says

    March 31, 2016 at 1:30 pm

    ERROR: FAILED TO RESOLVE:com.facebook.android:facebook-android-sdk:4.0.0′

    Reply
  52. priyanka kumawat says

    April 2, 2016 at 7:03 pm

    how to get user email addreess from facebook login??

    Reply
  53. Venja says

    April 12, 2016 at 2:39 pm

    Hi, first thanks for the tutorial, its easy to follow and implement..
    i have a question…
    After successful login, how and where can i use intent to go other activity..
    For now, after login also coming back to LoginActivity. Can you please clear the doubt?

    Reply
  54. VISHAL YADAV says

    April 23, 2016 at 5:42 pm

    @Override
    public void onSuccess(LoginResult loginResult) {

    // Facebook Email address
    GraphRequest request = GraphRequest.newMeRequest(
    loginResult.getAccessToken(),
    new GraphRequest.GraphJSONObjectCallback() {
    @Override
    public void onCompleted(
    JSONObject object,
    GraphResponse response) {
    Log.v(“LoginActivity Response “, response.toString());

    try {
    Toast.makeText(getApplicationContext(), “Name ” + object.getString(“name”)
    +”\nEmail “+object.getString(“email”), Toast.LENGTH_LONG).show();

    } catch (JSONException e) {
    e.printStackTrace();
    }
    }
    });
    Bundle parameters = new Bundle();
    parameters.putString(“fields”, “id,name,email,gender, birthday”);
    request.setParameters(parameters);
    request.executeAsync();

    }

    Reply
  55. Girish says

    April 26, 2016 at 7:06 am

    hi
    I want to use in my app login activity instead of fragment

    Reply
  56. vishnu says

    May 3, 2016 at 5:40 am

    APK build is successful but am gointing java.lang.NullPointerException: Attempt to invoke virtual method ‘int java.lang.Object.hashCode()’ on a null object reference error occur in catalog ..

    Reply
  57. Rabiul Bisaws says

    May 13, 2016 at 1:28 pm

    I am a php developer, Now I want to develop android app. Get some suggesion & tutorial link from which I learn very fast. Please help

    Reply
    • abhisek says

      June 13, 2016 at 6:39 am

      first be familiar with core java then start to learn android from youtube or tutorials pointand many other.

      Reply
  58. Manas says

    May 23, 2016 at 12:22 pm

    How to get all albums from facebook in nadroid programatically???
    please help me,,,

    Reply
  59. Manas says

    June 1, 2016 at 9:14 am

    how to get all album’s photos in android apps???

    Reply
  60. tom says

    June 9, 2016 at 11:00 am

    hey where is main activity ?????

    Reply
    • Pal says

      June 17, 2016 at 8:34 pm

      @tom- main activity is automatically generated when you choose blank activity with fragment….you dont need to do any modifications to it for this code.
      Hope it helped you 🙂

      Reply
  61. harryy says

    June 21, 2016 at 9:06 am

    i didn’t get output in mobile..when i click on login with Facebook it is loading and stopped, not shown login page in mobile.

    Reply
    • Heena Sharma says

      July 26, 2016 at 9:37 am

      same happened with me also it loading loading loading and then stopped pls help

      Reply
  62. narayan says

    July 1, 2016 at 7:27 am

    i want save user id and passward how to do plzzzzz help me out bro

    Reply
  63. Heena Sharma says

    July 21, 2016 at 10:21 am

    Hi Sir, The app is not working for me i am not able to understand where to put code should i make
    1.fragment (Blank Fragment)
    2.MainActivity
    3.activity_main.xml
    4.fragment.xml
    what to put in MainActivity ??????
    Please answer
    Thank you

    Reply
    • Syed Sami says

      August 16, 2016 at 7:01 am

      Yes you need to create a layout call it Fragment and add the code there for KeyHash

      Reply
  64. shikhil says

    July 25, 2016 at 7:09 pm

    i m getting a blank white screen . I Followed all the steps listed above.
    help me

    Reply
    • kate says

      August 2, 2016 at 6:06 pm

      same here, just a white screen but there’s no any syntax error

      Reply
  65. rajnish says

    September 14, 2016 at 7:08 pm

    where is the layout for fragment_main?

    Reply
  66. alok says

    September 20, 2016 at 11:20 am

    sir, how we create own button?

    Reply
  67. kanika says

    September 29, 2016 at 9:35 am

    find an error in mainactivity in setContentView() method

    Reply
  68. Suraj Chavan says

    October 1, 2016 at 6:07 am

    all working is fine but this code not run on android lollipop version…. why this is happened?…

    Reply
  69. kiniki says

    October 5, 2016 at 1:58 am

    Hi I’m just learning android and found it interesting to perform the user login but I can not do this supplement shows me red line last one:

    It happens that I have MainActivityFragment and really in the tutorial nowhere shown or MainActivityFragment is added and the truth is that I can put donot to make it work.
    Thank you.

    Reply
  70. Reda says

    November 19, 2016 at 1:45 pm

    Hello, i have implemented the code below and its work but i have a probleme when i try to log with another facebook account.
    Please have you an idea to solve the problem ?

    Thank’s
    Reda

    Reply
  71. mounika says

    April 17, 2017 at 5:46 am

    at the first time of login, i am getting profile null, what should i do?

    Reply
  72. Lun says

    September 26, 2017 at 4:24 am

    Can you do also the tutorial how to put the facebook detail like username , email to database mysql for android app? Thank You

    Reply
  73. Taru says

    October 29, 2017 at 7:43 am

    how to do it with custom button. Not using facebook inbuilt button.

    Reply
  74. md_husain says

    July 13, 2018 at 9:29 am

    the login works for only developer, i.e., my id. why not for other.
    when others login from it, an error appears that app is in development mode

    Reply

Leave a Reply to Nitin Cancel reply

Your email address will not be published. Required fields are marked *

Search




Download our Android App

Simplified Coding in Google Play

About Me

Belal Khan

Hello I am Belal Khan, founder and owner of Simplified Coding. I am currently pursuing MCA from St. Xavier's College, Ranchi. I love to share my knowledge over Internet.

Connect With Me

Follow @codesimplified
Simplified Coding

Popular Tutorials

  • Android JSON Parsing – Retrieve From MySQL Database
  • Android Login and Registration Tutorial with PHP MySQL
  • Android Volley Tutorial – Fetching JSON Data from URL
  • Android Upload Image to Server using Volley Tutorial
  • Android TabLayout Example using ViewPager and Fragments
  • Retrieve Data From MySQL Database in Android using Volley
  • Firebase Cloud Messaging Tutorial for Android
  • Android Volley Tutorial – User Registration and Login
  • Android Upload Image to Server Using PHP MySQL
  • Android Navigation Drawer Example using Fragments




About Simplified Coding

Simplified Coding is a blog for all the students learning programming. We are providing various tutorials related to programming and application development. You can get various nice and simplified tutorials related to programming, app development, graphics designing and animation. We are trying to make these things simplified and entertaining. We are writing text tutorial and creating video and visual tutorials as well. You can check about the admin of the blog here and check out our sitemap

Quick Links

  • Advertise Here
  • Privacy Policy
  • Disclaimer
  • About
  • Contact Us
  • Write for Us

Categories

Android Advance Android Application Development Android Beginners Android Intermediate Ionic Framework Tutorial JavaScript Kotlin Android Others PHP Advance PHP Tutorial React Native

Copyright © 2017 · Simplified Coding· All rights Reserved. And Our Sitemap.All Logos & Trademark Belongs To Their Respective Owners·

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.