Я получаю эту ошибку.
Не могу решить эту ошибку, помогите.
других ошибок в проекте нет.
Застрял на этом.
Основная деятельность
public class MainActivity extends AppCompatActivity {
String name, email;
FirebaseAuth mAuth;
Button submit;
DatabaseReference rootRef,demoRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title
getSupportActionBar().hide(); // hide the title bar
setContentView(R.layout.activity_main);
name = findViewById(R.id.uName);
email = findViewById(R.id.uEmail);
Я использую постоянный макет. Я установил все правильно.
<?xml version = "1.0" encoding = "utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background = "@drawable/background"
android:gravity = "center">
<EditText
android:id = "@+id/uName"
android:layout_width = "0dp"
android:layout_height = "58dp"
android:layout_marginStart = "48dp"
android:layout_marginLeft = "48dp"
android:layout_marginTop = "24dp"
android:layout_marginEnd = "48dp"
android:layout_marginRight = "48dp"
android:background = "@drawable/border"
android:hint = "@string/name"
android:paddingLeft = "5dp"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintHorizontal_bias = "0.0"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toBottomOf = "@+id/textView" />
ошибка
Unexpected implicit cast to String: layout tag was EditText less... (Ctrl+F1)
Inspection info:Keeps track of the view types associated with ids and if it finds a usage of the id in the Java code it ensures that it is treated as the same type. Issue id: WrongViewCast
Type parameter T has incompatible upper bounds: View and String




Привет, добро пожаловать в Stack Overflow
На самом деле вы пытаетесь получить ссылку на editText из своего макета.
name = findViewById(R.id.uName);
Переменная name не является переменной типа EditText. это переменная типа String. вот почему ваше приложение показывает исключение приведения.
Используйте EditText вместо String и замените
String name, email;
с участием
EditText name, email;
Глупая ошибка с моей стороны :(