应用程序在打开后自动关闭

时间:2014-10-23 09:00:33

标签: android xml android-layout android-activity wallpaper

我发布了xml代码,它没有在AVD和设备上运行: 我没有为Java编写任何逻辑,它只是一个空白文件,如下所示:

我面临的问题是我无法运行此应用程序,它在打开后自动关闭,我不知道为什么,我无法确定任何错误,因为6小时,请帮助,如果有任何错误,或如果需要任何其他信息

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Button;
import android.widget.ImageView;

public class SetWall extends Activity {

    ImageView IVdisplay, IVimage1,IVimage2, IVimage3, IVimage4, IVimage5, IVimage6 ;
    Button bsetwall;


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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.set_wall, menu);
        return true;
    }

}


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

    <ImageView
        android:src="@drawable/xda"
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:layout_gravity="center"
        android:contentDescription="@string/app_name_inside"
        android:id="@+id/IVdisplay"/>

    <HorizontalScrollView

        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

    <ImageView android:src="@drawable/xda1"
        android:layout_width="125dp"
        android:layout_height="125dp"
        android:padding="15dp"
        android:contentDescription="@string/app_name_inside"

        android:id="@+id/IVimage1"/>
    <ImageView android:src="@drawable/xda2"
        android:layout_width="125dp"
        android:layout_height="125dp"
        android:padding="15dp"
        android:contentDescription="@string/app_name_inside"

        android:id="@+id/IVimage2"/>
    <ImageView android:src="@drawable/xda3"
        android:layout_width="125dp"
        android:layout_height="125dp"
        android:padding="15dp"
        android:contentDescription="@string/app_name_inside"
        android:id="@+id/IVimage3"/>

    <ImageView android:src="@drawable/xda4"
        android:layout_width="125dp"
        android:layout_height="125dp"
        android:padding="15dp"
        android:contentDescription="@string/app_name_inside"
        android:id="@+id/IVimage4"/>

    <ImageView android:src="@drawable/xda5"
        android:layout_width="125dp"
        android:layout_height="125dp"
        android:padding="15dp"
        android:contentDescription="@string/app_name_inside"
        android:id="@+id/IVimage5"/>

    <ImageView android:src="@drawable/xda6"
        android:layout_width="125dp"
        android:layout_height="125dp"
        android:padding="15dp"
        android:contentDescription="@string/app_name_inside"
        android:id="@+id/IVimage6"/>
    </LinearLayout>

   </HorizontalScrollView>

    <Button
        android:id="@+id/bsetwall"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/setwallbutton" />

</LinearLayout>

这是我的清单文件:

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="delhi.digitek.androidlhdwallpapers.SetWall"
            android:label="@string/app_name_inside" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

LOGCAT文件:

> 10-23 08:44:14.962: D/dalvikvm(1338): Not late-enabling CheckJNI
> (already on) 10-23 08:44:20.432: D/dalvikvm(1338): GC_FOR_ALLOC freed
> 55K, 4% free 3091K/3216K, paused 58ms, total 61ms 10-23 08:44:20.442:
> I/dalvikvm-heap(1338): Grow heap (frag case) to 3.752MB for
> 702736-byte allocation 10-23 08:44:20.512: D/dalvikvm(1338):
> GC_FOR_ALLOC freed 2K, 4% free 3775K/3904K, paused 67ms, total 67ms
> 10-23 08:44:23.452: D/dalvikvm(1338): GC_FOR_ALLOC freed 2K, 3% free
> 3799K/3904K, paused 40ms, total 41ms 10-23 08:44:23.452:
> I/dalvikvm-heap(1338): Forcing collection of SoftReferences for
> 14004244-byte allocation 10-23 08:44:23.522: D/dalvikvm(1338):
> GC_BEFORE_OOM freed 9K, 3% free 3789K/3904K, paused 63ms, total 64ms
> 10-23 08:44:23.522: E/dalvikvm-heap(1338): Out of memory on a
> 14004244-byte allocation. 10-23 08:44:23.532: I/dalvikvm(1338): "main"
> prio=5 tid=1 RUNNABLE 10-23 08:44:23.532: I/dalvikvm(1338):   |
> group="main" sCount=0 dsCount=0 obj=0xb4a34c90 self=0xb8440380 10-23
> 08:44:23.532: I/dalvikvm(1338):   | sysTid=1338 nice=0 sched=0/0
> cgrp=apps handle=-1225678508 10-23 08:44:23.532: I/dalvikvm(1338):   |
> state=R schedstat=( 3680000000 3540000000 354 ) utm=301 stm=67 core=0
> 10-23 08:44:23.532: I/dalvikvm(1338):   at
> android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 10-23
> 08:44:23.532: I/dalvikvm(1338):   at
> android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)
> 10-23 08:44:23.532: I/dalvikvm(1338):   at
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:410)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.content.res.Resources.loadDrawable(Resources.java:2110) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.content.res.TypedArray.getDrawable(TypedArray.java:602) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.widget.ImageView.<init>(ImageView.java:129) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.widget.ImageView.<init>(ImageView.java:119) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> java.lang.reflect.Constructor.constructNative(Native Method) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> java.lang.reflect.Constructor.newInstance(Constructor.java:423) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.createView(LayoutInflater.java:594) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.inflate(LayoutInflater.java:492) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.inflate(LayoutInflater.java:397) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.view.LayoutInflater.inflate(LayoutInflater.java:353) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.app.Activity.setContentView(Activity.java:1928) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> delhi.digitek.androidlhdwallpapers.SetWall.onCreate(SetWall.java:18)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.app.Activity.performCreate(Activity.java:5243) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.app.ActivityThread.access$700(ActivityThread.java:135) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> android.os.Handler.dispatchMessage(Handler.java:102) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> android.os.Looper.loop(Looper.java:137) 10-23 08:44:23.542:
> I/dalvikvm(1338):   at
> android.app.ActivityThread.main(ActivityThread.java:4998) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> java.lang.reflect.Method.invokeNative(Native Method) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> java.lang.reflect.Method.invoke(Method.java:515) 10-23 08:44:23.542:
> I/dalvikvm(1338):   at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
> 10-23 08:44:23.542: I/dalvikvm(1338):   at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 10-23
> 08:44:23.542: I/dalvikvm(1338):   at
> dalvik.system.NativeStart.main(Native Method) 10-23 08:44:23.542:
> D/skia(1338): --- allocation failed for scaled bitmap 10-23
> 08:44:23.612: D/AndroidRuntime(1338): Shutting down VM 10-23
> 08:44:23.612: W/dalvikvm(1338): threadid=1: thread exiting with
> uncaught exception (group=0xb4a33b90) 10-23 08:44:23.702:
> E/AndroidRuntime(1338): FATAL EXCEPTION: main 10-23 08:44:23.702:
> E/AndroidRuntime(1338): Process: delhi.digitek.androidlhdwallpapers,
> PID: 1338 10-23 08:44:23.702: E/AndroidRuntime(1338):
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{delhi.digitek.androidlhdwallpapers/delhi.digitek.androidlhdwallpapers.SetWall}:
> android.view.InflateException: Binary XML file line #31: Error
> inflating class <unknown> 10-23 08:44:23.702: E/AndroidRuntime(1338):
>   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.app.ActivityThread.access$700(ActivityThread.java:135) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.os.Handler.dispatchMessage(Handler.java:102) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.os.Looper.loop(Looper.java:137) 10-23 08:44:23.702:
> E/AndroidRuntime(1338):   at
> android.app.ActivityThread.main(ActivityThread.java:4998) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> java.lang.reflect.Method.invokeNative(Native Method) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> java.lang.reflect.Method.invoke(Method.java:515) 10-23 08:44:23.702:
> E/AndroidRuntime(1338):   at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> dalvik.system.NativeStart.main(Native Method) 10-23 08:44:23.702:
> E/AndroidRuntime(1338): Caused by: android.view.InflateException:
> Binary XML file line #31: Error inflating class <unknown> 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.createView(LayoutInflater.java:620) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.inflate(LayoutInflater.java:492) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.inflate(LayoutInflater.java:397) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.inflate(LayoutInflater.java:353) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.app.Activity.setContentView(Activity.java:1928) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> delhi.digitek.androidlhdwallpapers.SetWall.onCreate(SetWall.java:18)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.app.Activity.performCreate(Activity.java:5243) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   ... 11 more 10-23
> 08:44:23.702: E/AndroidRuntime(1338): Caused by:
> java.lang.reflect.InvocationTargetException 10-23 08:44:23.702:
> E/AndroidRuntime(1338):   at
> java.lang.reflect.Constructor.constructNative(Native Method) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> java.lang.reflect.Constructor.newInstance(Constructor.java:423) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.view.LayoutInflater.createView(LayoutInflater.java:594) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     ... 26 more 10-23 08:44:23.702:
> E/AndroidRuntime(1338): Caused by: java.lang.OutOfMemoryError 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:410)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
> 10-23 08:44:23.702: E/AndroidRuntime(1338):   at
> android.content.res.Resources.loadDrawable(Resources.java:2110) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.content.res.TypedArray.getDrawable(TypedArray.java:602) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.widget.ImageView.<init>(ImageView.java:129) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     at
> android.widget.ImageView.<init>(ImageView.java:119) 10-23
> 08:44:23.702: E/AndroidRuntime(1338):     ... 29 more 10-23 08:44:26.422:
> I/Process(1338): Sending signal. PID: 1338 SIG: 9 10-23 08:45:21.512:
> D/dalvikvm(1381): GC_FOR_ALLOC freed 59K, 4% free 3091K/3220K, paused
> 53ms, total 56ms 10-23 08:45:21.522: I/dalvikvm-heap(1381): Grow heap
> (frag case) to 3.752MB for 702736-byte allocation 10-23 08:45:21.662:
> D/dalvikvm(1381): GC_FOR_ALLOC freed 2K, 4% free 3775K/3908K, paused
> 137ms, total 137ms 10-23 08:45:24.542: D/dalvikvm(1381): GC_FOR_ALLOC
> freed 2K, 3% free 3799K/3908K, paused 69ms, total 70ms 10-23
> 08:45:24.542: I/dalvikvm-heap(1381): Forcing collection of
> SoftReferences for 14004244-byte allocation 10-23 08:45:24.612:
> D/dalvikvm(1381): GC_BEFORE_OOM freed 9K, 4% free 3789K/3908K, paused
> 68ms, total 69ms 10-23 08:45:24.612: E/dalvikvm-heap(1381): Out of
> memory on a 14004244-byte allocation. 10-23 08:45:24.612:
> I/dalvikvm(1381): "main" prio=5 tid=1 RUNNABLE 10-23 08:45:24.612:
> I/dalvikvm(1381):   | group="main" sCount=0 dsCount=0 obj=0xb4a34c90
> self=0xb8440380 10-23 08:45:24.622: I/dalvikvm(1381):   | sysTid=1381
> nice=0 sched=0/0 cgrp=apps handle=-1225678508 10-23 08:45:24.622:
> I/dalvikvm(1381):   | state=R schedstat=( 3540000000 950000000 230 )
> utm=279 stm=75 core=0 10-23 08:45:24.622: I/dalvikvm(1381):   at
> android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 10-23
> 08:45:24.622: I/dalvikvm(1381):   at
> android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)
> 10-23 08:45:24.632: I/dalvikvm(1381):   at
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:410)
> 10-23 08:45:24.632: I/dalvikvm(1381):   at
> android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
> 10-23 08:45:24.632: I/dalvikvm(1381):   at
> android.content.res.Resources.loadDrawable(Resources.java:2110) 10-23
> 08:45:24.632: I/dalvikvm(1381):   at
> android.content.res.TypedArray.getDrawable(TypedArray.java:602) 10-23
> 08:45:24.632: I/dalvikvm(1381):   at
> android.widget.ImageView.<init>(ImageView.java:129) 10-23
> 08:45:24.632: I/dalvikvm(1381):   at
> android.widget.ImageView.<init>(ImageView.java:119) 10-23
> 08:45:24.632: I/dalvikvm(1381):   at
> java.lang.reflect.Constructor.constructNative(Native Method) 10-23
> 08:45:24.632: I/dalvikvm(1381):   at
> java.lang.reflect.Constructor.newInstance(Constructor.java:423) 10-23
> 08:45:24.632: I/dalvikvm(1381):   at
> android.view.LayoutInflater.createView(LayoutInflater.java:594) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.inflate(LayoutInflater.java:492) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.inflate(LayoutInflater.java:397) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.view.LayoutInflater.inflate(LayoutInflater.java:353) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.app.Activity.setContentView(Activity.java:1928) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> delhi.digitek.androidlhdwallpapers.SetWall.onCreate(SetWall.java:18)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.app.Activity.performCreate(Activity.java:5243) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.app.ActivityThread.access$700(ActivityThread.java:135) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> android.os.Handler.dispatchMessage(Handler.java:102) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> android.os.Looper.loop(Looper.java:137) 10-23 08:45:24.642:
> I/dalvikvm(1381):   at
> android.app.ActivityThread.main(ActivityThread.java:4998) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> java.lang.reflect.Method.invokeNative(Native Method) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> java.lang.reflect.Method.invoke(Method.java:515) 10-23 08:45:24.642:
> I/dalvikvm(1381):   at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
> 10-23 08:45:24.642: I/dalvikvm(1381):   at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 10-23
> 08:45:24.642: I/dalvikvm(1381):   at
> dalvik.system.NativeStart.main(Native Method) 10-23 08:45:24.642:
> D/skia(1381): --- allocation failed for scaled bitmap 10-23
> 08:45:24.712: D/AndroidRuntime(1381): Shutting down VM 10-23
> 08:45:24.712: W/dalvikvm(1381): threadid=1: thread exiting with
> uncaught exception (group=0xb4a33b90) 10-23 08:45:24.812:
> E/AndroidRuntime(1381): FATAL EXCEPTION: main 10-23 08:45:24.812:
> E/AndroidRuntime(1381): Process: delhi.digitek.androidlhdwallpapers,
> PID: 1381 10-23 08:45:24.812: E/AndroidRuntime(1381):
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{delhi.digitek.androidlhdwallpapers/delhi.digitek.androidlhdwallpapers.SetWall}:
> android.view.InflateException: Binary XML file line #31: Error
> inflating class <unknown> 10-23 08:45:24.812: E/AndroidRuntime(1381):
>   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.app.ActivityThread.access$700(ActivityThread.java:135) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.os.Handler.dispatchMessage(Handler.java:102) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.os.Looper.loop(Looper.java:137) 10-23 08:45:24.812:
> E/AndroidRuntime(1381):   at
> android.app.ActivityThread.main(ActivityThread.java:4998) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> java.lang.reflect.Method.invokeNative(Native Method) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> java.lang.reflect.Method.invoke(Method.java:515) 10-23 08:45:24.812:
> E/AndroidRuntime(1381):   at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> dalvik.system.NativeStart.main(Native Method) 10-23 08:45:24.812:
> E/AndroidRuntime(1381): Caused by: android.view.InflateException:
> Binary XML file line #31: Error inflating class <unknown> 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.createView(LayoutInflater.java:620) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.inflate(LayoutInflater.java:492) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.inflate(LayoutInflater.java:397) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.inflate(LayoutInflater.java:353) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.app.Activity.setContentView(Activity.java:1928) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> delhi.digitek.androidlhdwallpapers.SetWall.onCreate(SetWall.java:18)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.app.Activity.performCreate(Activity.java:5243) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   ... 11 more 10-23
> 08:45:24.812: E/AndroidRuntime(1381): Caused by:
> java.lang.reflect.InvocationTargetException 10-23 08:45:24.812:
> E/AndroidRuntime(1381):   at
> java.lang.reflect.Constructor.constructNative(Native Method) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> java.lang.reflect.Constructor.newInstance(Constructor.java:423) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.view.LayoutInflater.createView(LayoutInflater.java:594) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     ... 26 more 10-23 08:45:24.812:
> E/AndroidRuntime(1381): Caused by: java.lang.OutOfMemoryError 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:410)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
> 10-23 08:45:24.812: E/AndroidRuntime(1381):   at
> android.content.res.Resources.loadDrawable(Resources.java:2110) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.content.res.TypedArray.getDrawable(TypedArray.java:602) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.widget.ImageView.<init>(ImageView.java:129) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     at
> android.widget.ImageView.<init>(ImageView.java:119) 10-23
> 08:45:24.812: E/AndroidRuntime(1381):     ... 29 more

2 个答案:

答案 0 :(得分:1)

你在AndroidManifest.xml上注册了你的活动吗? 添加您的SetWall活动。 如果不是这样的话,请仔细查看您的logcat,它会告诉您错过的内容

引起:java.lang.OutOfMemoryError 10-23 08:44:23.702:E / AndroidRuntime(1338):at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)10-23 08:44:23.702:E / AndroidRuntime(1338):在android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)10-23 08:44:2

它说 - 由内存不足引起的错误。 这意味着你的形象太大了。首先测试小尺寸图像 如果您想要显示高质量的图像,您应该逐一显示它们。不是在同一时间。 在你的xml中,我看到包含很多图片。

在这种情况下,我建议您以编程方式使用

对于outofmemory问题,你应该做抽样。

BitmapFactory.Options option = new Options();
option.inSampleSize = 2;

(1表示原始,2表示对图像进行一半采样,3表示不支持等于2,4 ...,8 ...)

Bitmap samplingBitmap = BitmapFactory.decodeFile(path, option);
imageView.setImageBitmap(samplingBitmap);

我建议你使用资产文件夹。 将您的图像放在资产文件夹中,然后您的图像路径将为file:///android_asset/***.jpg

答案 1 :(得分:1)

抱歉,我发布此答案是因为我没有评论的声誉。 但由于你的异常是关于膨胀,bitmapfactory和outofmemoryexception,我想问题是关于你的布局中的imageview必须将大图像加载到你运行代码的设备的内存中。尝试删除您的图像视图的来源并在没有它们的情况下运行它。