Mudei o Intent do AndroidMnifest pra ver se o erro tava na chamada do recurso ou na própria Activity do formulário e percebi que provavelmente o erro está na Activity do formulário, visto que ao pedir pro aplicativo rodar no emulador, ele já abre com o erro destacado acima e fecha.
Poderiam me ajudar a localizar onde está o erro?
Segue abaixo o código do meu FormularioActivity.java:
package br.com.alura.agenda;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class FormularioActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_formulario);
Button botaoSalvar = (Button) findViewById(R.id.formulario_nota);
botaoSalvar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(FormularioActivity.this, "Salvo", Toast.LENGTH_SHORT).show();
}
});
}
}
Segue abaixo o código do meu activity_formulario.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nome"
android:id="@+id/formulario_nome"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Endereco"
android:id="@+id/formulario_endereco"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Telefone"
android:id="@+id/formulario_telefone"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Site"
android:id="@+id/formulario_site"/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:max="10"
android:layout_gravity="center"
android:id="@+id/formulario_nota"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Inserir"
android:id="@+id/formulario_salvar" />
</LinearLayout>
</ScrollView>
Segue abaixo o AndroidManifest com o Intent alterado pra classe Formulário Activity:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.alura.agenda">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ListaAlunosActivity">
</activity>
<activity android:name=".FormularioActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Segue, ainda, para mais informações, as mensagens de erro retornadas ao tentar executar a aplicação:
11/10 23:04:00: Launching app
$ adb shell am start -n "br.com.alura.agenda/br.com.alura.agenda.FormularioActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Waiting for process to come online
Connected to process 3360 on device Nexus_5X_API_23 [emulator-5554]
W/System: ClassLoader referenced unknown path: /data/app/br.com.alura.agenda-1/lib/x86
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.alura.agenda, PID: 3360
java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.alura.agenda/br.com.alura.agenda.FormularioActivity}: java.lang.ClassCastException: android.support.v7.widget.AppCompatRatingBar cannot be cast to android.widget.Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatRatingBar cannot be cast to android.widget.Button
at br.com.alura.agenda.FormularioActivity.onCreate(FormularioActivity.java:16)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I/Process: Sending signal. PID: 3360 SIG: 9
Application terminated.