Hi everyone. I'm teaching myself Android and it's been nothing but trouble. I'm having difficulty even doing some of the simplest tasks. Anyways, I've created a login screen, and when the user presses "OK", I want to switch activities, but it's not working. Here're my Logcat erros:
10-26 10:24:23.779: E/Trace(952): error opening trace file: No such file or directory (2)
10-26 10:24:29.988: E/AndroidRuntime(952): FATAL EXCEPTION: main
10-26 10:24:29.988: E/AndroidRuntime(952): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hecst/com.hecst.MainMenu}: android.view.InflateException: Binary XML file line #2: Error inflating class menu
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.os.Handler.dispatchMessage(Handler.java:99)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.os.Looper.loop(Looper.java:137)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-26 10:24:29.988: E/AndroidRuntime(952): at java.lang.reflect.Method.invokeNative(Native Method)
10-26 10:24:29.988: E/AndroidRuntime(952): at java.lang.reflect.Method.invoke(Method.java:511)
10-26 10:24:29.988: E/AndroidRuntime(952): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-26 10:24:29.988: E/AndroidRuntime(952): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-26 10:24:29.988: E/AndroidRuntime(952): at dalvik.system.NativeStart.main(Native Method)
10-26 10:24:29.988: E/AndroidRuntime(952): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class menu
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-26 10:24:29.988: E/AndroidRuntime(952): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.Activity.setContentView(Activity.java:1867)
10-26 10:24:29.988: E/AndroidRuntime(952): at com.hecst.MainMenu.onCreate(MainMenu.java:15)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.Activity.performCreate(Activity.java:5008)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
10-26 10:24:29.988: E/AndroidRuntime(952): ... 11 more
10-26 10:24:29.988: E/AndroidRuntime(952): Caused by: java.lang.ClassNotFoundException: android.view.menu
10-26 10:24:29.988: E/AndroidRuntime(952): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-26 10:24:29.988: E/AndroidRuntime(952): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-26 10:24:29.988: E/AndroidRuntime(952): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
10-26 10:24:29.988: E/AndroidRuntime(952): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
10-26 10:24:29.988: E/AndroidRuntime(952): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
10-26 10:24:29.988: E/AndroidRuntime(952): ... 20 more
Here's my XML file I think it's referring to:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:name="Main Menu">
<item android:id="@+id/set_sched_form_prefs"
android:title="@string/set_sched_form_prefs" />
<item android:id="@+id/set_notifications"
android:title="@string/set_notifications" />
<item android:id="@+id/update_calendar"
android:title="@string/update_calendar" />
</menu>
And here's the code that's supposed to call the new Activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button ok = (Button)findViewById(R.id.ok);
ok.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, MainMenu.class);
startActivity(intent);
}
});
}
Does anyone have any ideas? I've done a bit of research on this error, but the only solutions I could find involved reducing image sizes, but my app doesn't have any images yet.
Thanks for your help, and have a better day than I'm having! :)