unable to render facebook login button on android studio -


i'm facing strange problem facebook login button of facebook android sdk 4. i've follow guide convert previous code (i've used old facebook sdk), android studio not render correctly button. login button code:

<com.facebook.login.widget.loginbutton     xmlns:fb="http://schemas.android.com/apk/res-auto"     android:id="@+id/fb_button"     style="@style/facebookloginbutton"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_above="@+id/my_button"     android:layout_centerhorizontal="true"     android:layout_marginbottom="-14dp"     android:textsize="34sp"     fb:login_text="@string/login_with_facebook"     fb:logout_text="logout" /> 

wbhere facebook login button style is

 <style name="facebookloginbutton">     <item name="android:background">@drawable/button_facebook</item>     <item name="android:textcolor">@color/white</item>     <item name="android:textsize">21sp</item>     <item name="android:gravity">center</item> 

now when try see preview on android studio, i've error:

java.lang.noclassdeffounderror: not initialize class com.facebook.login.widget.loginbutton @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:408) @ org.jetbrains.android.uipreview.viewloader.createnewinstance(viewloader.java:413) @ org.jetbrains.android.uipreview.viewloader.loadview(viewloader.java:105) @ com.android.tools.idea.rendering.layoutlibcallback.loadview(layoutlibcallback.java:176) @ android.view.bridgeinflater.loadcustomview(bridgeinflater.java:207) @ android.view.bridgeinflater.createviewfromtag(bridgeinflater.java:132) @ android.view.layoutinflater.rinflate_original(layoutinflater.java:806) @ android.view.layoutinflater_delegate.rinflate(layoutinflater_delegate.java:64) @ android.view.layoutinflater.rinflate(layoutinflater.java:782) @ android.view.layoutinflater.inflate(layoutinflater.java:504) @ android.view.layoutinflater.inflate(layoutinflater.java:385) @ com.android.layoutlib.bridge.impl.rendersessionimpl.inflate(rendersessionimpl.java:410) @ com.android.layoutlib.bridge.bridge.createsession(bridge.java:321) @ com.android.ide.common.rendering.layoutlibrary.createsession(layoutlibrary.java:350) @ com.android.tools.idea.rendering.renderservice$5.compute(renderservice.java:708) @ com.android.tools.idea.rendering.renderservice$5.compute(renderservice.java:697) @ com.intellij.openapi.application.impl.applicationimpl.runreadaction(applicationimpl.java:932) @ com.android.tools.idea.rendering.renderservice.createrendersession(renderservice.java:697) @ com.android.tools.idea.rendering.renderservice.render(renderservice.java:816) @ com.intellij.android.designer.designsurface.androiddesignereditorpanel$6.run(androiddesignereditorpanel.java:480) @ com.intellij.util.ui.update.mergingupdatequeue.execute(mergingupdatequeue.java:320) @ com.intellij.util.ui.update.mergingupdatequeue.execute(mergingupdatequeue.java:310) @ com.intellij.util.ui.update.mergingupdatequeue$2.run(mergingupdatequeue.java:254) @ com.intellij.util.ui.update.mergingupdatequeue.flush(mergingupdatequeue.java:269) @ com.intellij.util.ui.update.mergingupdatequeue.flush(mergingupdatequeue.java:227) @ com.intellij.util.ui.update.mergingupdatequeue.run(mergingupdatequeue.java:217) @ com.intellij.util.concurrency.queueprocessor.runsafely(queueprocessor.java:238) @ com.intellij.util.alarm$request$1.run(alarm.java:327) @ java.util.concurrent.executors$runnableadapter.call(executors.java:511) @ java.util.concurrent.futuretask.run(futuretask.java:266) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ java.lang.thread.run(thread.java:745) 

what's wrong?

you need override oncreate, oncreateview , onviewcreated in fragment.

something this:

@override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     facebooksdk.sdkinitialize(getactivity().getapplicationcontext());     callbackmanager = callbackmanager.factory.create(); }  @override public void onviewcreated(view view, @nullable bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);     loginbutton = (loginbutton) view.findviewbyid(r.id.login_button);     loginbutton.setreadpermissions("email", "user_likes", "user_friends");     loginbutton.setfragment(this);     setfacebooklogintext(loginbutton);     // other app specific specialization      // callback registration     loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() {         @override         public void onsuccess(loginresult loginresult) {             toast.maketext(getactivity(), "success", toast.length_short).show();         }          @override         public void oncancel() {             toast.maketext(getactivity(), "fail", toast.length_short).show();         }          @override         public void onerror(facebookexception exception) {             toast.maketext(getactivity(), "error", toast.length_short).show();         }     });  }  @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view view = inflater.inflate(r.layout.fragment_facebook_login, container, false);     return view; }   @override public void onactivityresult(int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);     callbackmanager.onactivityresult(requestcode, resultcode, data); } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -