java - 从输入流读取错误 - 无法解析符号

标签 java android sqlite layout textview

我的 SQLite 登录和注册应用程序突然决定崩溃。 textViewLinkRegister 的 ID 有问题。有人可以帮帮我吗??

    <?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>

请引用上一个AppCompatView。 接下来是 Login.class,因为 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);
    }
}

所有的组合我都试过了,结果还是输了。 private AppCompatTextView textViewLinkRegister; 是问题所在,如果更改为 AppCompatTextViewLinkRegister,则无法正常工作。 我还能做什么?

错误日志

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) 

最佳答案

检查你是否为真实设备添加了权限

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

并且在模拟器上没有麦克风所以它发生错误

所以试试this用于在模拟器上工作

或尝试禁用麦克风使用 this post

关于java - 从输入流读取错误 - 无法解析符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51318201/

相关文章:

java - 为什么柑橘测试框架中的包扫描没有采用我们指定的模式的所有 xml 测试用例

java - Android MVP - Mockito 测试不传递 eq(ObjectDTO),但传递从中提取值

python - 如何编写此查询?

mysql - 优化生成的字符串以存储到数据库中

SQL 查询 - 列表字段

java - 哈希集与树集

java - 映射键在 Groovy 中是不是对象?

java - Railo Java 错误 : java. io.FileNotFoundException

android - 如何将相对布局设置为默认布局

android - 使用 k-soap2 在 Android 中读取字节数组