title: Any Example showing how to login using Facebook SDK 4.0 in Android either by using own button or Facebook Button?
body: <p>Is there any tutorial or example showing how to login using own Button using <strong>Facebook SDK 4.0</strong> in <strong>Android</strong>? I am not getting anywhere and using facebook developers site it is difficult to understand.Like below when calling <strong>FBlogin</strong> button I want to check go for login if user has not logged in or if logged in I want the access token to get facebook profile information and user likes.</p>
  
  <pre><code>FBlogin.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
               //Facebook login Code to get profile info and user likes  
          }
      });
  </code></pre>
  
  <p>I have tried also loginButton Facebook.</p>
  
  <pre><code>  &lt;com.facebook.login.widget.LoginButton
              android:id="@+id/login_button"
              android:layout_width="244dp"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:layout_marginTop="30dp"
              android:layout_marginBottom="30dp" 
  
  /&gt;
  </code></pre>
  
  <p>But it is showing error in xml :-</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class com.facebook.login.widget.LoginButton
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
      at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
      at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
      at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176)
      at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:206)
      at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:131)
      at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:739)
      at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:711)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:372)
      at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:369)
      at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:326)
      at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
      at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:708)
      at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697)
      at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
      at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697)
      at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
      at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
      at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
      at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
      at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
      at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
      at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
      at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
      at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
      at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
      at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
      at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
      at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>My Activity class:-</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState)  {
          super.onCreate(savedInstanceState);
          FacebookSdk.sdkInitialize(getApplicationContext());
          setContentView(R.layout.activity_main);
  </code></pre>
  
  <p>Ia there any example/tutorial to login using facebook sdk4.0? I am stuck in both way. Please help.</p>