java - ClassNotFoundException with Parse and Facebook -
i hoping can me problem facing. trying integrate facebook login app using parse, , classnotfoundexception error, when call method
parsefacebookutils.loginwithreadpermissionsinbackground(loginactivity.this, permissions, new logincallback()
the error stack trace:
05-15 10:36:00.749 3936-3936/kstr14.tipper e/androidruntime﹕ fatal exception: main process: kstr14.tipper, pid: 3936 java.lang.illegalstateexception: not execute method of activity @ android.view.view$1.onclick(view.java:4007) @ android.view.view.performclick(view.java:4756) @ android.view.view$performclick.run(view.java:19749) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) caused by: java.lang.reflect.invocationtargetexception @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ android.view.view$1.onclick(view.java:4002) @ android.view.view.performclick(view.java:4756) @ android.view.view$performclick.run(view.java:19749) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) caused by: java.lang.noclassdeffounderror: failed resolution of: lcom/parse/parsetaskutils; @ com.parse.parsefacebookutils.loginwithreadpermissionsinbackground(parsefacebookutils.java:173) @ kstr14.tipper.activities.loginactivity.facebookloginpressed(loginactivity.java:170) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ android.view.view$1.onclick(view.java:4002) @ android.view.view.performclick(view.java:4756) @ android.view.view$performclick.run(view.java:19749) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) caused by: java.lang.classnotfoundexception: didn't find class "com.parse.parsetaskutils" on path: dexpathlist[[zip file "/data/app/kstr14.tipper-1/base.apk"],nativelibrarydirectories=[/vendor/lib, /system/lib]] @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56) @ java.lang.classloader.loadclass(classloader.java:511) @ java.lang.classloader.loadclass(classloader.java:469) @ com.parse.parsefacebookutils.loginwithreadpermissionsinbackground(parsefacebookutils.java:173) @ kstr14.tipper.activities.loginactivity.facebookloginpressed(loginactivity.java:170) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ android.view.view$1.onclick(view.java:4002) @ android.view.view.performclick(view.java:4756) @ android.view.view$performclick.run(view.java:19749) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5221) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) suppressed: java.lang.classnotfoundexception: com.parse.parsetaskutils @ java.lang.class.classforname(native method) @ java.lang.bootclassloader.findclass(classloader.java:781) @ java.lang.bootclassloader.loadclass(classloader.java:841) @ java.lang.classloader.loadclass(classloader.java:504) ... 16 more caused by: java.lang.noclassdeffounderror: class not found using boot class loader; no stack available
i have following jar files in lib folder: parse-1.9.1.jar javax.mail.jar bolts-android-1.2.0.jar parsefacebookutilsv4-1.9.2.jar
i have tried various things dependencies part of build.gradle file, suspect error due library not being included correctly, none of have tried have worked. i've tried different ways of specifying compiling jar files specifying jars in different orders. build.gradle file looks this:
apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { applicationid "kstr14.tipper" minsdkversion 21 targetsdkversion 21 versioncode 1 versionname "1.0" } buildtypes { debug { debuggable true } release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } productflavors { } } repositories { mavencentral() } dependencies { compile filetree(include: ['*.jar'] ,dir: 'libs') compile files('libs/bolts-android-1.2.0.jar') compile 'com.parse.bolts:bolts-android:1.2.0' compile files('libs/parse-1.9.1.jar') compile files('libs/parsefacebookutilsv4-1.9.2.jar') compile files('libs/javax.mail.jar') compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.facebook.android:facebook-android-sdk:4.0.0' compile 'com.google.android.gms:play-services:7.0.0' }
anyone have suggestions?
oh , way, when app crashes due error, press ok, , facebook login screen shows anyway.. suppose facebook jar being imported fine, , problem within parse jars. however, have been using pars jar before tried integrate facebook, , worked fine. imported bolts jar @ same time imported facebook jar, read somewhere necessary, might problem bolts jar?
edit: added code loginactivity:
package kstr14.tipper.activities; import android.content.intent; import android.os.bundle; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmenttransaction; import android.support.v7.app.actionbaractivity; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.window; import android.widget.edittext; import android.widget.toast; import com.facebook.facebooksdk; import com.parse.logincallback; import com.parse.parseexception; import com.parse.parsefacebookutils; import com.parse.parseobject; import com.parse.parseuser; import com.parse.signupcallback; import java.util.arraylist; import java.util.list; import javax.mail.internet.addressexception; import javax.mail.internet.internetaddress; import kstr14.tipper.data.category; import kstr14.tipper.data.group; import kstr14.tipper.data.tip; import kstr14.tipper.r; public class loginactivity extends actionbaractivity { // ui elements default login fragment private edittext usernamedefaultlogin; private edittext passworddefaultlogin; // ui elements sign fragment private edittext usernamesignup; private edittext emailsignup; private edittext passwordsignup; private edittext reenterpasswordsignup; @override protected void oncreate(bundle savedinstancestate) { getwindow().requestfeature(window.feature_action_bar); super.oncreate(savedinstancestate); setcontentview(r.layout.activity_login); getsupportactionbar().hide(); // initalize facebook facebooksdk.sdkinitialize(getapplicationcontext()); // initialize parse parseobject.registersubclass(tip.class); parseobject.registersubclass(category.class); parseobject.registersubclass(group.class); parseobject.registersubclass(parseuser.class); // check cache current user - if found go directly mainactivity parseuser currentuser = parseuser.getcurrentuser(); if(currentuser != null) { intent intent = new intent(getapplicationcontext(), mainactivity.class); startactivity(intent); } // otherwise set fragment default login screen defaultloginfragment defaultloginfragment = new defaultloginfragment(); getsupportfragmentmanager().begintransaction() .add(r.id.fragment_container, defaultloginfragment).commit(); } // required making facebook login work @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); parsefacebookutils.onactivityresult(requestcode, resultcode, data); } /** * method called when sign button pressed on default login fragment * switches default login fragment sign fragment * @param view */ public void defaultsignuppressed(view view) { signupfragment signupfragment = new signupfragment(); fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction(); // replace default login fragment sign fragment, // , add transaction stack user can navigate fragmenttransaction.replace(r.id.fragment_container, signupfragment); fragmenttransaction.addtobackstack(null); fragmenttransaction.commit(); } /** * method called when login button pressed on default login fragment * attempts log in user, if successful goes mainactivity * @param view */ public void defaultloginpressed(view view) { // initialize ui elements default login fragment usernamedefaultlogin = (edittext) findviewbyid(r.id.usernamedefaultloginfragment); passworddefaultlogin = (edittext) findviewbyid(r.id.passworddefaultloginfragment); // fetch input , attempt login string username = usernamedefaultlogin.gettext().tostring(); string password = passworddefaultlogin.gettext().tostring(); parseuser.logininbackground(username, password, new logincallback() { public void done(parseuser user, parseexception e) { if (user != null) { intent intent = new intent(getapplicationcontext(), mainactivity.class); startactivity(intent); } else { toast.maketext(getapplicationcontext(), "login failed.", toast.length_short).show(); } } }); } /** * method called when sign button pressed in sign fragment * attempts register user, if successful goes mainactivity * @param view */ public void signuppressed(view view) { // ui elements sign fragment usernamesignup = (edittext) findviewbyid(r.id.usernamesignupfragment); emailsignup = (edittext) findviewbyid(r.id.emailsignupfragment); passwordsignup = (edittext) findviewbyid(r.id.passwordsignupfragment); reenterpasswordsignup = (edittext) findviewbyid(r.id.reenterpasswordsignupfragment); string username = usernamesignup.gettext().tostring(); string email = emailsignup.gettext().tostring(); string password1 = passwordsignup.gettext().tostring(); string password2 = reenterpasswordsignup.gettext().tostring(); // validate passwords , email if(!validatepassword(password1, password2)) { toast.maketext(getapplicationcontext(), "passwords not match, try again.", toast.length_short).show(); } else if (!validateemail(email)) { toast.maketext(getapplicationcontext(), "please enter valid email.", toast.length_short).show(); } else { parseuser user = new parseuser(); user.setusername(username); user.setpassword(password1); user.setemail(email); user.signupinbackground(new signupcallback() { public void done(parseexception e) { if (e == null) { intent intent = new intent(getapplicationcontext(), mainactivity.class); startactivity(intent); } else { toast.maketext(getapplicationcontext(), "sign failed. please try again.", toast.length_short).show(); } } }); } } public void facebookloginpressed(view view) { list<string> permissions = new arraylist<string>(); permissions.add("public_profile"); parsefacebookutils.loginwithreadpermissionsinbackground(loginactivity.this, permissions, new logincallback() { @override public void done(parseuser user, parseexception err) { if (user == null) { log.d("myapp", "uh oh. user cancelled facebook login."); } else if (user.isnew()) { log.d("myapp", "user signed , logged in through facebook!"); } else { log.d("myapp", "user logged in through facebook!"); } } }); } /** * validates 2 passwords equal * @param password1 * @param password2 * @return */ public boolean validatepassword(string password1, string password2) { if(password1.equals(password2)) return true; else return false; } /** * validates structure of email address * @param email * @return */ public boolean validateemail(string email) { boolean result = true; try { internetaddress internetaddress = new internetaddress(email); internetaddress.validate(); } catch (addressexception e) { e.printstacktrace(); result = false; } return result; } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu_login, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } }
i ran same problem. can save lot of headache searching issue. answer not use older sdk. needed sure using same version of parse , parsefacebookutils. @ gradle file above
compile 'com.parse.bolts:bolts-android:1.2.0' compile files('libs/parse-1.9.1.jar') compile files('libs/parsefacebookutilsv4-1.9.2.jar')
you using parse-1.9.1 , parsefacebookutilsv4-1.9.2. made same mistake. pulled parse-1.9.1 project , downloaded sdk again pull facebookutils library out.
Comments
Post a Comment