Cab_Russell
Cab_Russell

Reputation: 1

Complete beginner following Androids tutorial for first app - Fatal Java error

So I'm on Mac osx, downloaded Android studio, downloaded intel HAXM, started scripting and got to the end of this tutorial:

https://developer.android.com/training/basics/firstapp/building-ui.html

The script actually runs, but when I go to run it through my emulator the emulator says "My First App has stopped working" and I get the below in the debug menu.

I followed the instructions carefully and have a basic understanding of Java so but am not familiar with Android whatsoever. Could anyone let me know where I'm going wrong?

Thanks in advance!

Cab_Russell

02-24 22:41:24.798    2781-2781/com.example.dannyrussell.myfirstapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.dannyrussell.myfirstapp, PID: 2781
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dannyrussell.myfirstapp/com.example.dannyrussell.myfirstapp.MyActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class button
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
        at android.app.ActivityThread.access$800(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        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:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
 Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class button
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
        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 android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
        at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
        at com.example.dannyrussell.myfirstapp.MyActivity.onCreate(MyActivity.java:14)
        at android.app.Activity.performCreate(Activity.java:5933)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)

           

Upvotes: 0

Views: 58

Answers (1)

antlersoft
antlersoft

Reputation: 14751

The problem is identified in the stack trace (although perhaps obscurely).

When creating the view, Android creates Java objects for objects in the layout XML. It is saying it can't create a Java object for class "button". Since the class you probably want is "Button", make sure your layout XML is correct (it is case sensitive)

Upvotes: 1

Related Questions