我有SQLite登录并注册了突然决定崩溃的应用程序。 ID textViewLinkRegister
出现问题。有人可以帮我吗?
<?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)
答案 0 :(得分:1)
检查您是否已添加真实设备的权限
<uses-permission android:name="android.permission.RECORD_AUDIO" />
并在emulator not have microphone
上出现错误
请尝试使用this进行模拟器
或禁用麦克风尝试this post
答案 1 :(得分:1)
如果您查看日志,则有两行可疑:
07-13 05:41:28.225 5012-22952 / com.google.android.googlequicksearchbox:search W / ErrorProcessor:onFatalError,正在处理来自引擎(4)的错误
和
起因:com.google.android.apps.gsa.shared.exception.GsaIOException:错误代码:393238 |缓冲区溢出,没有可用空间。
似乎语音输入Google QuickSearchBox引起了您的错误,因为它试图访问模拟器上没有的麦克风。
此问题已在https://jsfiddle.net/eywraw8t/169950/中解决。请在那里看看。