1

I have SQLite login and register app that suddenly decided to crash. There was a problem with the id of textViewLinkRegister. Can someone help me out??

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:id="@+id/nestedScrollView"
    android:background="@drawable/ok"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp"
    tools:context="activities.LoginActivity"
    >


    <android.support.v7.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
       >


        <android.support.v7.widget.AppCompatImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:src="@drawable/logo"
            android:layout_marginTop="20dp"
             />

        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayoutName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp" >



            <android.support.design.widget.TextInputEditText
                android:id="@+id/textInputEditTextName"
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="20dp"
                android:layout_marginTop="40dp"
                android:layout_marginRight="60dp"
                android:hint="@string/hint_name"
                android:textColorHint="@color/colorPrimaryDark"
                android:inputType="text"
                android:maxLines="1"
                android:textColor="@color/colorPrimaryDark"
                android:textSize="20dp"/>
        </android.support.design.widget.TextInputLayout>


        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayoutEmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp" >

            <android.support.design.widget.TextInputEditText
                android:id="@+id/textInputEditTextEmail"
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="20dp"
                android:layout_marginTop="40dp"
                android:layout_marginRight="60dp"
                android:hint="@string/hint_email"
                android:textColorHint="@color/colorPrimaryDark"
                android:inputType="text"
                android:maxLines="1"
                android:textColor="@color/colorPrimaryDark"/>
        </android.support.design.widget.TextInputLayout>


        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayoutPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp" >

            <android.support.design.widget.TextInputEditText
                android:id="@+id/textInputEditTextPassword"
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="20dp"
                android:layout_marginTop="40dp"
                android:layout_marginRight="60dp"
                android:hint="@string/hint_password"
                android:inputType="textPassword"
                android:maxLines="1"
                android:textColor="@color/colorPrimaryDark"
                android:textColorHint="@color/colorPrimaryDark" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayoutConfirmPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp" >

            <android.support.design.widget.TextInputEditText
                android:id="@+id/textInputEditTextConfirmPassword"
                android:layout_width="300dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="20dp"
                android:layout_marginTop="40dp"
                android:layout_marginRight="60dp"
                android:hint="@string/hint_confirm_password"
                android:textColorHint="@color/colorPrimaryDark"
                android:inputType="textPassword"
                android:maxLines="1"
                android:textColor="@color/colorPrimaryDark" />
        </android.support.design.widget.TextInputLayout>

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/appCompatButtonRegister"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:textColor="@color/colorText"
            android:background="@color/colorTextHint"
            android:text="@string/text_register" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/appCompatTextViewRegisterLink"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:gravity="center"
            android:text="@string/text_already_member"
            android:textSize="16sp"
            android:textColor="@color/colorPrimaryDark" />
    </android.support.v7.widget.LinearLayoutCompat>

</android.support.v4.widget.NestedScrollView>

Please refer to the last AppCompatView. Next is the Login.class where everything seemed to crush because of the TextViewLinkRegister

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
    private final AppCompatActivity activity = LoginActivity.this;

    private NestedScrollView nestedScrollView;

    private TextInputLayout textInputLayoutEmail;
    private TextInputLayout textInputLayoutPassword;

    private TextInputEditText textInputEditTextEmail;
    private TextInputEditText textInputEditTextPassword;

    private AppCompatButton appCompatButtonLogin;

    private AppCompatTextView textViewLinkRegister;

    private InputValidation inputValidation;
    private DatabaseHelper databaseHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        getSupportActionBar().hide();

        initViews();
        initListeners();
        initObjects();
    }

    /**
     * This method is to initialize views
     */
    private void initViews() {

        nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);

        textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
        textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);

        textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
        textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);

        appCompatButtonLogin = (AppCompatButton) findViewById(R.id.appCompatButtonLogin);

        textViewLinkRegister = (AppCompatTextView) findViewById(R.id.appCompatTextViewRegisterLink)

    }

    /**
     * This method is to initialize listeners
     */
    private void initListeners() {
        appCompatButtonLogin.setOnClickListener(this);
        textViewLinkRegister.setOnClickListener(this);
    }

    /**
     * This method is to initialize objects to be used
     */
    private void initObjects() {
        databaseHelper = new DatabaseHelper(activity);
        inputValidation = new InputValidation(activity);

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.appCompatButtonLogin:
                verifyFromSQLite();
                break;
            case R.id.appCompatTextViewRegisterLink:
                // Navigate to RegisterActivity
                Intent intentRegister = new Intent(getApplicationContext(), RegisterActivity.class);
                startActivity(intentRegister);
                break;
        }
    }

    /**
     * This method is to validate the input text fields and verify login credentials from SQLite
     */
    private void verifyFromSQLite() {
        if (!inputValidation.isInputEditTextFilled(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
            return;
        }
        if (!inputValidation.isInputEditTextEmail(textInputEditTextEmail, textInputLayoutEmail, getString(R.string.error_message_email))) {
            return;
        }
        if (!inputValidation.isInputEditTextFilled(textInputEditTextPassword, textInputLayoutPassword, getString(R.string.error_message_email))) {
            return;
        }

        if (databaseHelper.checkUser(textInputEditTextEmail.getText().toString().trim()
                , textInputEditTextPassword.getText().toString().trim())) {


            Intent accountsIntent = new Intent(activity, UsersActivity.class);
            accountsIntent.putExtra("EMAIL", textInputEditTextEmail.getText().toString().trim());
            emptyInputEditText();
            startActivity(accountsIntent);


        } else {
            // Snack Bar to show success message that record is wrong
            Snackbar.make(nestedScrollView, getString(R.string.error_valid_email_password), Snackbar.LENGTH_LONG).show();
        }
    }

    /**
     * This method is to empty all input edit text
     */
    private void emptyInputEditText() {
        textInputEditTextEmail.setText(null);
        textInputEditTextPassword.setText(null);
    }
}

I have tried all the combinations and I lost it. private AppCompatTextView textViewLinkRegister; is the problem and it's not working if changed to AppCompatTextViewLinkRegister. What else can I do?

Error log

07-13 05:41:28.225 5012-22952/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4)
com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream
    at com.google.android.apps.gsa.staticplugins.microdetection.d.k.a(SourceFile:91)
    at com.google.android.apps.gsa.staticplugins.microdetection.d.l.run(Unknown Source:14)
    at com.google.android.libraries.gsa.runner.a.a.b(SourceFile:32)
    at com.google.android.libraries.gsa.runner.a.c.call(Unknown Source:4)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4)
    at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
    at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
    at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
 Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
    at com.google.android.apps.gsa.speech.audio.Tee.j(SourceFile:103)
    at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2)
    at java.io.InputStream.read(InputStream.java:101)
    at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:17)
    at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4) 
    at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 
    at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
    at java.lang.Thread.run(Thread.java:764) 
    at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6) 
Bhagyashri
  • 182
  • 1
  • 15
Lavinia Rotaru
  • 51
  • 1
  • 11
  • add log to question – Rohit Chauhan Jul 13 '18 at 05:36
  • I did below, can you help me please? – Lavinia Rotaru Jul 13 '18 at 05:45
  • Does this happen on a real device or on an emulator? – W3hri Jul 13 '18 at 05:56
  • @Lavinia Rotaru why you are not using simple TextView imnstead of using AppCompatTextView?and there is not such error pointing towards AppCompatTextView in your logcat. – Bhagyashri Jul 13 '18 at 05:59
  • This is happening on an emulator, i had the app working fine back-end, once i started to change designs of layouts, it went down with one first error: "Cannot resolve symbol textViewLinkRegister" and there I started to change.. I don't want to mess up the code anymore so I'm leaving it as AppCompat.. It's not pointing towards AppCompatTextView but "Error reading from input stream"- what is that? – Lavinia Rotaru Jul 13 '18 at 06:08

2 Answers2

1

check you have added permissions for real device

<uses-permission android:name="android.permission.RECORD_AUDIO" />

and on emulator not have microphone so it occurs error

so try this for working on emulator

or disable microphone use for try this post

Omkar
  • 3,040
  • 1
  • 22
  • 42
1

If you have a look at your logs, there are two lines that are suspicious:

07-13 05:41:28.225 5012-22952/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4)

and

Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.

It seems that the speech input Google QuickSearchBox is causing your error, because it tries to access the microphone, which is not present on the emulator.

This problem has been solved in his post. Please have a look there.

W3hri
  • 1,563
  • 2
  • 18
  • 31