exception - Could not find method (view) in android -


i create app here link of app onlinecontact app running fine when installed android studio connecting mobile it. when installed play store crashed debug play store app , find error unexpected because there no such error when directly run app android studio.

log

 java.lang.illegalstateexception: not find method createaccount(view) in parent or ancestor context android:onclick attribute defined on view class android.support.v7.widget.appcompatbutton id 'btncreateaccount'   d/accessibilitymanager: setstatelocked: wasenabled = false, misenabled = false, wastouchexplorationenabled = false, mistouchexplorationenabled = false, washightextcontrastenabled = false, mishightextcontrastenabled = false                                                      java.lang.throwable: setstatelocked 

second 1 not error show when app crashed. these error loginactivity here code.
loginactivity

 public class loginactivity extends appcompatactivity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_login); }  protected void login(view view){     edittext etxtphonenumber = (edittext) findviewbyid(r.id.etxtphonenumber);     edittext etxtpassword = (edittext) findviewbyid(r.id.etxtpassword);     string phonenumber = etxtphonenumber.gettext().tostring();     string password = etxtpassword.gettext().tostring();     string action = "login";      backgroundworker backgroundworker = new backgroundworker(this);     backgroundworker.execute(action, phonenumber, password); }   protected void forgetpassactivity(view view){     startactivity(new intent(this, forgetpassword.class)); }  protected void createaccount(view view){     intent loginintent = new intent(this, createaccount.class);     startactivity(loginintent); }  @override public void onbackpressed() {     movetasktoback(true); }  } 

mainactivity

 public class mainactivity extends appcompatactivity {  public static string shared_pref_filename = "com.azeem.onlinecontact.mysharedpref"; sharedpreferences sharedpref; interstitialad interstitialad;  @requiresapi(api = build.version_codes.m) @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     // placing ads in application      mobileads.initialize(this, "ca-app-pub-xxxx");     adview adview = (adview) findviewbyid(r.id.adview);     adrequest adrequest = new adrequest.builder().build();     adview.loadad(adrequest);      interstitialad = new interstitialad(this);     interstitialad.setadunitid("ca-app-pub-xxxxx");     interstitialad.loadad(adrequest);     interstitialad.setadlistener(new adlistener(){         @override         public void onadloaded() {             if(interstitialad.isloaded()){                 interstitialad.show();             }         }     });         sharedpref = getsharedpreferences(shared_pref_filename, mode_private);         boolean login = sharedpref.getboolean("login", false);         if (login) {                // send user login activity             intent mainactivity = new intent(this, loginactivity.class);             startactivity(mainactivity);        }        // rest of code. 

activity_login.xml

   <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">  <edittext     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:inputtype="textpassword"     android:ems="10"     android:layout_below="@+id/etxtphonenumber"     android:layout_alignleft="@+id/etxtphonenumber"     android:layout_alignstart="@+id/etxtphonenumber"     android:layout_margintop="39dp"     android:id="@+id/etxtpassword"     android:hint="@string/enter_password" />  <button     android:text="@string/login"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_below="@+id/etxtpassword"     android:layout_centerhorizontal="true"     android:layout_margintop="31dp"     android:id="@+id/btnlogin"     android:onclick="login"     style="@style/widget.appcompat.button.colored" />  <button     android:text="@string/create_account"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginbottom="45dp"     android:id="@+id/btncreateaccount"     android:layout_alignparentbottom="true"     android:layout_centerhorizontal="true"     android:onclick="createaccount"     style="@style/widget.appcompat.button.colored" />  <edittext     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:inputtype="phone"     android:ems="10"     android:layout_margintop="147dp"     android:id="@+id/etxtphonenumber"     android:hint="@string/your_phone_number"     android:layout_alignparenttop="true"     android:layout_centerhorizontal="true" />  <textview     android:text="@string/online_contact"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/textview"     android:textappearance="@style/textappearance.appcompat.display1"     android:layout_marginright="38dp"     android:layout_marginend="38dp"     android:layout_alignparenttop="true"     android:layout_alignparentright="true"     android:layout_alignparentend="true"     android:layout_margintop="54dp" />  <textview     android:text="@string/foget_password_click_here"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_above="@+id/btncreateaccount"     android:layout_centerhorizontal="true"     android:layout_marginbottom="24dp"     android:id="@+id/tvforgetpassword"     android:onclick="forgetpassactivity" />     </relativelayout>     

i check stackoverflow answers kind of error come when didn't declare onclick function or not passing view etc. think there other error. remember same code working fine when run app android studio

replace below 3 methods in loginactivity

public void login(view view){     edittext etxtphonenumber = (edittext) findviewbyid(r.id.etxtphonenumber);     edittext etxtpassword = (edittext) findviewbyid(r.id.etxtpassword);     string phonenumber = etxtphonenumber.gettext().tostring();     string password = etxtpassword.gettext().tostring();     string action = "login";      backgroundworker backgroundworker = new backgroundworker(this);     backgroundworker.execute(action, phonenumber, password); }  public void forgetpassactivity(view view){     startactivity(new intent(this, forgetpassword.class)); }  public void createaccount(view view){     intent loginintent = new intent(this, createaccount.class);     startactivity(loginintent); } 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -