当前位置: 首页 > 知识库问答 >
问题:

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

宿文栋
2023-03-14

我有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。接下来是登录。类,因为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);
    }
}

我尝试了所有的组合,但都失败了<代码>私有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) 

共有2个答案

凌通
2023-03-14

如果您查看日志,有两行是可疑的:

07-13 05:41:28.225 5012-22952/com.google.android.googlequicksearchbox:搜索W/Error处理器:onFatalError,处理来自引擎的错误(4)

原因:com.google.Android应用程序。gsa。共享。例外GsaIOException:错误代码:393238 |缓冲区溢出,没有可用空间。

语音输入Google QuickSearchBox似乎导致了您的错误,因为它试图访问模拟器上不存在的麦克风。

这个问题在他的岗位上得到了解决。请看那里。

於炯
2023-03-14

检查您是否为real device添加了权限

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

而且在模拟器上没有麦克风,所以出现了错误

所以在emulator上试试这个

或禁用麦克风用于尝试此帖子

 类似资料:
  • 问题内容: 我正在使用从运行约一分钟的进程中读取stdout。 我该如何stdout以流方式打印出该流程的每一行,以便可以看到生成的输出,但仍然阻止该流程终止,然后再继续? 似乎一次给出所有输出。 问题答案: 这是一个简单的示例(不检查错误): 如果ls结束太快,则while循环可能会在你读取所有数据之前结束。 你可以通过以下方式在中捕获其余部分:

  • 我的Android Studio不断给出错误,无法解析符号R。它是Android目录中名为R.java的文件。我已将此文件安全地保存在目录中。但它仍然显示出错误。在互联网上搜索到这个错误后,人们建议我重新构建/清理/升级项目同步/重新启动Android Studio和其他方法。我什么都做了。但问题仍然存在!怎么办??

  • 我试图在我的Android项目中设置一个RecycerView,但是我不能引用我的列表,因为使用代码“RecycerView=view.findviewbyid(r.id.list)”给我的错误不能解析符号“list”。如果我尝试输入“R.ID”我找不到r.id.list,但我确定我给它的id是“list”。 我只是在代码中添加了依赖项和import语句。我试图重新同步和清理项目,但没有结果。 这

  • 这里是我的导入: 这里是错误的代码: 这里是xml文件中RecyclerView的声明:

  • 我的Android Studio一直在给出错误不能解析符号R。它是Android目录中的一个文件,名为r.java。我把这个文件安全地放在目录里。但是,它仍然显示出错误。在网上搜索到这个错误后,人们建议我做重建/清理/分级项目同步/重启Android Studio等方法。我什么都做了。但问题仍然存在!怎么办??