Приложение закрывается с самого начала, у меня есть другой проект с почти таким же кодом, и этого не происходит.
Я уже прочитал некоторую информацию об этом, но это не помогает решить мою проблему,Одним из вариантов была проверка пакета, но в моем случае это правильно.
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#103DA3"
tools:context=".MainActivity">
<EditText
android:id="@+id/txt_usuario"
android:layout_width="212dp"
android:layout_height="44dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="236dp"
android:layout_marginEnd="97dp"
android:layout_marginRight="97dp"
android:background="@drawable/borde_redondo_et"
android:ems="10"
android:gravity="center_horizontal|center_vertical"
android:hint="@string/txt_usuario"
android:inputType="textPersonName"
android:shadowColor="#A71818"
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textIsSelectable="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.968"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/txt_contrasena"
android:layout_width="214dp"
android:layout_height="45dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="52dp"
android:layout_marginEnd="99dp"
android:layout_marginRight="99dp"
android:background="@drawable/borde_redondo_et"
android:ems="10"
android:gravity="center_horizontal|center_vertical"
android:hint="@string/txt_contraseña"
android:inputType="textPassword"
android:textColor="#FFFFFD"
android:textColorHighlight="#070000"
android:textColorHint="#FFFFFF"
android:textColorLink="#7C1414"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_usuario" />
<Button
android:id="@+id/btn_registro"
android:layout_width="131dp"
android:layout_height="45dp"
android:layout_marginStart="56dp"
android:layout_marginLeft="56dp"
android:layout_marginTop="80dp"
android:background="@drawable/botones"
android:onClick="Registrar"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_contrasena"
tools:text="@string/btn_registrar" />
<Button
android:id="@+id/btn_inicio"
android:layout_width="136dp"
android:layout_height="45dp"
android:layout_marginTop="80dp"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:background="@drawable/botones"
android:onClick="Ingresar"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_contrasena"
tools:text="@string/btn_ingresar" />
</LinearLayout>
Activity:
package com.example.prototipo2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private EditText et_usuario, et_contrasena;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_usuario = findViewById(R.id.txt_usuario);
et_contrasena = findViewById(R.id.txt_contrasena);
}
//Método botón Registrar
public void Registrar(View view) {
Intent registro = new Intent(this, RegistroActivity.class);
startActivity(registro);
}
//Método botón Ingresar
public void Ingresar(View view) {
MySQLiteOpenHelper admin = new MySQLiteOpenHelper(this, "administracion", null, 1);
SQLiteDatabase BasedeDatos = admin.getWritableDatabase();
String usuario = et_usuario.getText().toString();
String contrasena = et_contrasena.getText().toString();
if (!usuario.isEmpty()) {
//INvestigar consulta BD
Cursor fila = BasedeDatos.rawQuery("select usuario_id, contraseña from Usuarios where usuario_id = '" + usuario + "'", null);
if (fila.moveToFirst()) {
String user = fila.getString(0);
String pass = fila.getString(1);
if (usuario.equals(user) && contrasena.equals(pass)) {
//Pasar a la otra Actividad
Toast.makeText(this, "Ingreso exitoso", Toast.LENGTH_SHORT).show();
BasedeDatos.close();
Intent PrincipalActivity = new Intent(this, PrincipalActivity.class);
//PrincipalActivity.putExtra("user", usuario);
startActivity(PrincipalActivity);
}
else{
Toast.makeText(this, "Contraseña incorrecta", Toast.LENGTH_SHORT).show();
et_usuario.setText("");
et_contrasena.setText("");
}
BasedeDatos.close();
}
else {
Toast.makeText(this, "El usuario no existe", Toast.LENGTH_SHORT).show();
et_usuario.setText("");
et_contrasena.setText("");
BasedeDatos.close();
}
}
else {
Toast.makeText(this, "Debes introducir el usuario", Toast.LENGTH_SHORT).show();
}
}
}
Error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.prototipo2, PID: 22350
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.prototipo2/com.example.prototipo2.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5631)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class EditText
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.prototipo2.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6092)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5631)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.prototipo2:drawable/borde_redondo_et" (7f060058) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060058 a=-1 r=0x7f060058}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2719)
at android.content.res.Resources.loadDrawable(Resources.java:2643)
at android.content.res.TypedArray.getDrawable(TypedArray.java:761)
at android.view.View.<init>(View.java:3791)
at android.widget.TextView.<init>(TextView.java:665)
at android.widget.EditText.<init>(EditText.java:70)
at android.widget.EditText.<init>(EditText.java:66)
at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:73)
at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:69)
at androidx.appcompat.app.AppCompatViewInflater.createEditText(AppCompatViewInflater.java:197)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:115)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.prototipo2.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6092)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2595)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5631)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
На данный момент я просто хочу, чтобы приложение открылось. Спасибо