0

So I am using a tutorial to create my first app. I am using my phone as the emulator (HTC One X with version 4.0.3 android) I have no errors in my coding but for some reason I am getting a 'unfortunately app has stopped'. I have tried changing the version it runs on from between 2.2 up to 4.0.3 but none of them help. Here is my error log and coding (simple coding so hopefully be easy fixed)

ERROR LOG

    06-09 12:37:20.630: D/AndroidRuntime(18583): Shutting down VM
06-09 12:37:20.650: W/dalvikvm(18583): threadid=1: thread exiting with uncaught exception (group=0x40a65228)
06-09 12:37:20.660: E/AndroidRuntime(18583): FATAL EXCEPTION: main
06-09 12:37:20.660: E/AndroidRuntime(18583): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.regoreminder/com.regoreminder.RegoReminderActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class imageview
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.os.Looper.loop(Looper.java:156)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.ActivityThread.main(ActivityThread.java:5005)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at java.lang.reflect.Method.invokeNative(Native Method)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at java.lang.reflect.Method.invoke(Method.java:511)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at dalvik.system.NativeStart.main(Native Method)
06-09 12:37:20.660: E/AndroidRuntime(18583): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class imageview
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.Activity.setContentView(Activity.java:1897)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at com.regoreminder.RegoReminderActivity.onCreate(RegoReminderActivity.java:13)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.Activity.performCreate(Activity.java:4543)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158)
06-09 12:37:20.660: E/AndroidRuntime(18583):    ... 11 more
06-09 12:37:20.660: E/AndroidRuntime(18583): Caused by: java.lang.ClassNotFoundException: android.view.imageview
06-09 12:37:20.660: E/AndroidRuntime(18583):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:636)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
06-09 12:37:20.660: E/AndroidRuntime(18583):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
06-09 12:37:20.660: E/AndroidRuntime(18583):    ... 21 more

JAVA package com.regoreminder;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class RegoReminderActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
            Thread logoTimer = new Thread(){
                public void run(){
                    try{
                        int logoTimer = 0;
                        while(logoTimer <5000) {
                            sleep (100);
                            logoTimer = logoTimer +100;

                        }
                        startActivity(new Intent("com.regoreminder.CLEARSCREEN"));
                    }   catch (InterruptedException e)  {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    finally{
                        finish();
                    }
                }


            };
            logoTimer.start();
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }

    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
    }

    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
    }

MANIFEST

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.regoreminder"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity
            android:name=".RegoReminderActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Title"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.regoreminder.CLEARSCREEN" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MAIN

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/background"
    >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Continue" 
        android:gravity="center"/>

</LinearLayout>

SPLASH

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <imageview
        android:src="@drawable/titlebackground"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>

If anyone can offer some help as to what I have done wrong that would be awesome! I have been following a tutorial so I am not sure whats wrong. Also lookde all over the net for an answer but everyone Apps are different.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • If you look at your exception stack trace you noce that the last "Caused by" states the real error: "java.lang.ClassNotFoundException: android.view.imageview". As others noted the proper name is "ImageView". You search your code + configuration for "imageview" and find that you have in SPLASH. – Attila Jun 09 '12 at 03:34
  • possible duplicate of [Unfortunately MyApp has stopped. How can I solve this?](http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – Code-Apprentice Jul 25 '14 at 18:49

4 Answers4

5

Change this

<imageview
        android:src="@drawable/titlebackground"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

To

  <ImageView  
            android:src="@drawable/titlebackground"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
Vipul
  • 27,808
  • 7
  • 60
  • 75
2

imageview should be ImageView (note the case)

John Boker
  • 82,559
  • 17
  • 97
  • 130
2

[...] I am using a tutorial to create my first app.

Welcome to the world of programming ...

Other answers have told you what the problem it and how to fix it. But what you need to learn is how to diagnose solve these problems for yourself. And it basically involves learning to read a stack trace.

If you look at the stack trace, you will see a bunch of sections:

java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.regoreminder/com.regoreminder.RegoReminderActivity}:
    android.view.InflateException: Binary XML file line #7: Error
    inflating class imageview
    ...
Caused by: android.view.InflateException: Binary XML file line #7: 
    Error inflating class imageview
    ...
Caused by: java.lang.ClassNotFoundException: android.view.imageview

    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.view.LayoutInflater.createView(LayoutInflater.java:552)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:636)
    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)

The first section is the primary exception stacktrace, and the others are for a series of nested / chained exceptions ... where one exception has been caught, and another has been created and thrown with the first one as the cause.

Now look at the actual messages. Each one is talking about a class called "imageview". Indeed, the last one gives the fully qualified name of the class "android.view.imageview" ... and says the exception namer is "ClassNotFoundException". This exception basically means what it says. The VM (or more specifically the class loader) can't find the class with that name. (And you'll see the class / method names of the class loaders in the trace.)

Why?

Because it doesn't exist. Or to be precise, no class exists with that capitalization. All Java and Android classes are capitalized, so you'd never see a class called "imageview" in a Java or Android.

So then you should ask yourself "where did this incorrect classname come from"? It won't be in your source code (unless you are using reflection) because you'll see a compilation error if you use the wrong classname for a library class. So it must be your configs. And a quick search reveals ... indeed ... that that it where the name comes from. And once again, there is confirmatory evidence in the stack trace, in the last 2 lines of the stack trace:

    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)

The names implies it is trying to create a view within a layout, and that the view name comes from an XML tag.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
-1

Your views should always be in Upper case. In your case "ImageView"

Neha
  • 245
  • 5
  • 17