android - Error running simple wall paper application
<p>Im very new to android programming. Im trying to learn android by creating a simple app that will set wall paper background. I admit there are lots of basic concepts in android development that I still don't know and understand so please be kind to me.</p>

<p>Im using Android SDK 4.1, Eclipse Indigo. </p>

<p>I set my AVD specs:</p>

<pre><code>CPU/ABI: ARM (armeabi-v7a)
Target: Android 4.1 (API level 16)
Skin: WVGA800 
SD Card: 512
</code></pre>

<p>I am having an error everytime I run the application.</p>

<p>The error:</p>

<pre>
<code>
08-11 14:11:51.733: E/Trace(696): error opening trace file: No such file or directory (2)
08-11 14:11:52.383: D/dalvikvm(696): GC_FOR_ALLOC freed 44K, 3% free 8054K/8259K, paused 44ms, total 45ms
08-11 14:11:52.443: I/dalvikvm-heap(696): Grow heap (frag case) to 14.643MB for 7056016-byte allocation
08-11 14:11:52.534: D/dalvikvm(696): GC_CONCURRENT freed 1K, 2% free 14943K/15175K, paused 25ms+5ms, total 85ms
08-11 14:11:53.093: D/dalvikvm(696): GC_FOR_ALLOC freed (ImageView.java:120)
08-11 14:11:53.724: I/dalvikvm(696):   at android.widget.ImageView.(ImageView.java:110)
08-11 14:11:53.724: I/dalvikvm(696):   at java.lang.reflect.Constructor.constructNative(Native Method)
08-11 14:11:53.724: I/dalvikvm(696):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-11 14:11:53.763: I/dalvikvm(696):   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-11 14:11:53.763: I/dalvikvm(696):   at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-11 14:11:53.763: I/dalvikvm(696):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
08-11 14:11:53.763: I/dalvikvm(696):   at android.app.Activity.setContentView(Activity.java:1867)
08-11 14:11:53.763: I/dalvikvm(696):   at com.example.androidwallpaper.MainActivity.onCreate(MainActivity.java:12)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.Activity.performCreate(Activity.java:5008)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-11 14:11:53.773: I/dalvikvm(696):   at android.os.Handler.dispatchMessage(Handler.java:99)
08-11 14:11:53.773: I/dalvikvm(696):   at android.os.Looper.loop(Looper.java:137)
08-11 14:11:53.773: I/dalvikvm(696):   at android.app.ActivityThread.main(ActivityThread.java:4745)
08-11 14:11:53.773: I/dalvikvm(696):   at java.lang.reflect.Method.invokeNative(Native Method)
08-11 14:11:53.773: I/dalvikvm(696):   at java.lang.reflect.Method.invoke(Method.java:511)
08-11 14:11:53.773: I/dalvikvm(696):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-11 14:11:53.773: I/dalvikvm(696):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-11 14:11:53.773: I/dalvikvm(696):   at dalvik.system.NativeStart.main(Native Method)
08-11 14:11:53.804: D/skia(696): --- decoder->decode returned false
08-11 14:11:53.804: D/AndroidRuntime(696): Shutting down VM
08-11 14:11:53.804: W/dalvikvm(696): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-11 14:11:53.823: E/AndroidRuntime(696): FATAL EXCEPTION: main
08-11 14:11:53.823: E/AndroidRuntime(696): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidwallpaper/com.example.androidwallpaper.MainActivity}: android.view.InflateException: Binary XML file line #43: Error inflating class 
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.os.Looper.loop(Looper.java:137)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.ActivityThread.main(ActivityThread.java:4745)
08-11 14:11:53.823: E/AndroidRuntime(696):  at java.lang.reflect.Method.invokeNative(Native Method)
08-11 14:11:53.823: E/AndroidRuntime(696):  at java.lang.reflect.Method.invoke(Method.java:511)
08-11 14:11:53.823: E/AndroidRuntime(696):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-11 14:11:53.823: E/AndroidRuntime(696):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-11 14:11:53.823: E/AndroidRuntime(696):  at dalvik.system.NativeStart.main(Native Method)
08-11 14:11:53.823: E/AndroidRuntime(696): Caused by: android.view.InflateException: Binary XML file line #43: Error inflating class 
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-11 14:11:53.823: E/AndroidRuntime(696):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-11 14:11:53.823: E/AndroidRuntime(696):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.Activity.setContentView(Activity.java:1867)
08-11 14:11:53.823: E/AndroidRuntime(696):  at com.example.androidwallpaper.MainActivity.onCreate(MainActivity.java:12)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.Activity.performCreate(Activity.java:5008)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-11 14:11:53.823: E/AndroidRuntime(696):  ... 11 more
08-11 14:11:53.823: E/AndroidRuntime(696): Caused by: java.lang.reflect.InvocationTargetException
08-11 14:11:53.823: E/AndroidRuntime(696):  at java.lang.reflect.Constructor.constructNative(Native Method)
08-11 14:11:53.823: E/AndroidRuntime(696):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-11 14:11:53.823: E/AndroidRuntime(696):  ... 26 more
08-11 14:11:53.823: E/AndroidRuntime(696): Caused by: java.lang.OutOfMemoryError
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.content.res.Resources.loadDrawable(Resources.java:1930)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.widget.ImageView.(ImageView.java:120)
08-11 14:11:53.823: E/AndroidRuntime(696):  at android.widget.ImageView.(ImageView.java:110)
08-11 14:11:53.823: E/AndroidRuntime(696):  ... 29 more
08-11 14:11:59.383: I/Process(696): Sending signal. PID: 696 SIG: 9
</code>
</pre>

<p>My codes are as follows:</p>

<p><b><code>activity_main.xml</code> </b></p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" &gt;

&lt;ImageView
    android:id="@+id/IVDisplay"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:src="@drawable/wp1" /&gt;

&lt;Button
    android:id="@+id/bSetWallPaper"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Set Wallpaper" /&gt;

&lt;HorizontalScrollView
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center" &gt;

    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" &gt;

        &lt;ImageView
            android:id="@+id/IVimage1"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp1" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage2"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp2" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage3"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp3" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage4"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp4" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage5"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp5" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage6"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp6" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage7"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp7" /&gt;

        &lt;ImageView
            android:id="@+id/IVimage8"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/wp8" /&gt;
    &lt;/LinearLayout&gt;
&lt;/HorizontalScrollView&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p><b> <code>MainActivity.java</code></b></p>

<pre><code>package com.example.androidwallpaper;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void setWallPaper (View view) {
        new AlertDialog.Builder(this).setTitle("Codes").setMessage("Put codes here later!").
        setNeutralButton("Close", null).show();  
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
</code></pre>

<p><b><code>AndroidManifest.xml</code></b></p>

<pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidwallpaper"
android:versionCode="1"
android:versionName="1.0" &gt;

&lt;uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" /&gt;

&lt;application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" &gt;
    &lt;activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
&lt;/application&gt;

&lt;/manifest&gt;
</code></pre>

<p>Below is the screenshot of the error.</p>

<p><img src="http://i.stack.imgur.com/A3Ukg.png" alt="enter image description here"></p>

<p>Below is the screenshot of the graphical layout.</p>

<p><img src="http://i.stack.imgur.com/D8DjC.png" alt="enter image description here"></p>

<p>Please help. I really really need help. </p>
