问题描述
我在我的模拟器上开发并测试了一个应用程序,它的 API 为 4.1 (Jelly Bean).当我在我的实际设备(三星 Galaxy Nexus)上调试我的应用程序时,它在 logcat-Fatal signal 11 (SIGSEGV) 中为我提供了 0x00000000(代码 = 1),线程 4395.你能帮忙吗?
I developed and tested an application on my emulator that had an API of 4.1 (Jelly Bean). When I debug my application on my actual device, which is a Samsung Galaxy Nexus, it gives me in the logcat- Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 4395. Can you help?
Java XML:
package ID;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
public class Menu extends Activity implements OnClickListener {
ImageView display;
int toPhone;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_wallpapers);
toPhone = R.drawable.eye;
display = (ImageView) findViewById(R.id.IVdisplay);
ImageView image1 = (ImageView) findViewById(R.id.IVimage1);
ImageView image2 = (ImageView) findViewById(R.id.IVimage2);
ImageView image3 = (ImageView) findViewById(R.id.IVimage3);
ImageView image4 = (ImageView) findViewById(R.id.IVimage4);
ImageView image5 = (ImageView) findViewById(R.id.IVimage5);
ImageView image6 = (ImageView) findViewById(R.id.IVimage6);
ImageView image7 = (ImageView) findViewById(R.id.IVimage7);
Button setWall = (Button) findViewById(R.id.button1);
image1.setOnClickListener(this);
image2.setOnClickListener(this);
image3.setOnClickListener(this);
image4.setOnClickListener(this);
image5.setOnClickListener(this);
image6.setOnClickListener(this);
image7.setOnClickListener(this);
setWall.setOnClickListener(this);
}
@SuppressWarnings("deprecation")
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.IVimage1:
display.setImageResource(R.drawable.eye);
toPhone = R.drawable.eye;
break;
case R.id.IVimage2:
display.setImageResource(R.drawable.falls);
toPhone = R.drawable.falls;
break;
case R.id.IVimage3:
display.setImageResource(R.drawable.inthemiddle);
toPhone = R.drawable.inthemiddle;
break;
case R.id.IVimage4:
display.setImageResource(R.drawable.web);
toPhone = R.drawable.web;
break;
case R.id.IVimage5:
display.setImageResource(R.drawable.watching);
toPhone = R.drawable.watching;
break;
case R.id.IVimage6:
display.setImageResource(R.drawable.similar);
toPhone = R.drawable.similar;
break;
case R.id.IVimage7:
display.setImageResource(R.drawable.solar);
toPhone = R.drawable.solar;
break;
case R.id.button1:
InputStream cont = getResources().openRawResource(R.drawable.eye);
Bitmap background = BitmapFactory.decodeStream(cont);
try {
getApplicationContext().setWallpaper(background);
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
Java XML:
package ID;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import ab.wallpapers.hd.R;
public class Wallpapers extends Activity {
@Override
protected void onCreate(Bundle Wallpapers) {
super.onCreate(Wallpapers);
setContentView(R.layout.activity_wallpapers);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
}
@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 onStop() {
// TODO Auto-generated method stub
super.onStop();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_wallpapers, menu);
return true;
}
Logcat:
09-24 20:34:11.619: I/System.out(5225): Sending WAIT chunk
09-24 20:34:11.619: W/ActivityThread(5225): Application ab.wallpapers.hd is waiting for the debugger on port 8100...
09-24 20:34:11.643: I/dalvikvm(5225): Debugger is active
09-24 20:34:11.822: I/System.out(5225): Debugger has connected
09-24 20:34:11.822: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:12.025: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:12.221: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:12.424: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:12.627: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:12.830: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:13.033: I/System.out(5225): waiting for debugger to settle...
09-24 20:34:13.236: I/System.out(5225): debugger has settled (1435)
09-24 20:34:13.393: D/dalvikvm(5225): GC_FOR_ALLOC freed 39K, 2% free 10842K/11011K, paused 17ms, total 18ms
09-24 20:34:13.400: I/dalvikvm-heap(5225): Grow heap (frag case) to 13.618MB for 3145744-byte allocation
09-24 20:34:13.432: D/dalvikvm(5225): GC_CONCURRENT freed 1K, 2% free 13912K/14151K, paused 12ms+2ms, total 27ms
09-24 20:34:13.650: D/dalvikvm(5225): GC_FOR_ALLOC freed 0K, 2% free 13912K/14151K, paused 12ms, total 12ms
09-24 20:34:13.666: I/dalvikvm-heap(5225): Grow heap (frag case) to 18.949MB for 5591056-byte allocation
09-24 20:34:13.697: D/dalvikvm(5225): GC_CONCURRENT freed 0K, 2% free 19372K/19655K, paused 11ms+3ms, total 28ms
09-24 20:34:14.033: D/dalvikvm(5225): GC_FOR_ALLOC freed 3072K, 18% free 16308K/19655K, paused 10ms, total 10ms
09-24 20:34:14.041: I/dalvikvm-heap(5225): Grow heap (frag case) to 18.957MB for 3145744-byte allocation
09-24 20:34:14.088: D/dalvikvm(5225): GC_CONCURRENT freed <1K, 2% free 19380K/19655K, paused 12ms+19ms, total 45ms
09-24 20:34:14.143: D/dalvikvm(5225): GC_FOR_ALLOC freed 0K, 2% free 19380K/19655K, paused 12ms, total 12ms
09-24 20:34:14.150: I/dalvikvm-heap(5225): Grow heap (frag case) to 24.289MB for 5591056-byte allocation
09-24 20:34:14.174: D/dalvikvm(5225): GC_CONCURRENT freed 0K, 2% free 24841K/25159K, paused 2ms+2ms, total 25ms
09-24 20:34:14.838: D/dalvikvm(5225): GC_FOR_ALLOC freed 3072K, 14% free 21770K/25159K, paused 10ms, total 10ms
09-24 20:34:14.853: I/dalvikvm-heap(5225): Grow heap (frag case) to 28.321MB for 7372816-byte allocation
09-24 20:34:14.885: D/dalvikvm(5225): GC_CONCURRENT freed <1K, 11% free 28970K/32391K, paused 13ms+2ms, total 25ms
09-24 20:34:15.088: D/dalvikvm(5225): GC_FOR_ALLOC freed 0K, 11% free 28970K/32391K, paused 10ms, total 10ms
09-24 20:34:15.119: I/dalvikvm-heap(5225): Grow heap (frag case) to 40.824MB for 13109776-byte allocation
09-24 20:34:15.143: D/dalvikvm(5225): GC_CONCURRENT freed 0K, 8% free 41772K/45255K, paused 12ms+3ms, total 30ms
09-24 20:34:16.228: D/dalvikvm(5225): GC_FOR_ALLOC freed 7200K, 24% free 34573K/45255K, paused 11ms, total 11ms
09-24 20:34:16.236: I/dalvikvm-heap(5225): Grow heap (frag case) to 40.825MB for 7372816-byte allocation
09-24 20:34:16.283: D/dalvikvm(5225): GC_CONCURRENT freed <1K, 8% free 41773K/45255K, paused 13ms+8ms, total 49ms
09-24 20:34:16.283: D/dalvikvm(5225): WAIT_FOR_CONCURRENT_GC blocked 37ms
09-24 20:34:16.502: D/dalvikvm(5225): GC_FOR_ALLOC freed 0K, 8% free 41773K/45255K, paused 15ms, total 15ms
09-24 20:34:16.525: I/dalvikvm-heap(5225): Grow heap (frag case) to 53.327MB for 13109776-byte allocation
09-24 20:34:16.557: D/dalvikvm(5225): GC_CONCURRENT freed 0K, 7% free 54576K/58119K, paused 11ms+3ms, total 28ms
09-24 20:34:17.533: D/dalvikvm(5225): GC_FOR_ALLOC freed 7200K, 19% free 47377K/58119K, paused 14ms, total 14ms
09-24 20:34:17.541: I/dalvikvm-heap(5225): Grow heap (frag case) to 53.329MB for 7372816-byte allocation
09-24 20:34:17.580: D/dalvikvm(5225): GC_CONCURRENT freed <1K, 7% free 54577K/58119K, paused 12ms+3ms, total 40ms
09-24 20:34:17.799: D/dalvikvm(5225): GC_FOR_ALLOC freed 0K, 7% free 54577K/58119K, paused 19ms, total 19ms
09-24 20:34:17.799: I/dalvikvm-heap(5225): Forcing collection of SoftReferences for 13109776-byte allocation
09-24 20:34:17.877: D/dalvikvm(5225): GC_BEFORE_OOM freed 9K, 7% free 54568K/58119K, paused 71ms, total 74ms
09-24 20:34:17.877: E/dalvikvm-heap(5225): Out of memory on a 13109776-byte allocation.
09-24 20:34:17.877: I/dalvikvm(5225): "main" prio=5 tid=1 RUNNABLE
09-24 20:34:17.877: I/dalvikvm(5225): | group="main" sCount=0 dsCount=0 obj=0x40d9e568 self=0x40d8e9f8
09-24 20:34:17.877: I/dalvikvm(5225): | sysTid=5225 nice=0 sched=0/0 cgrp=apps/bg_non_interactive handle=1075160624
09-24 20:34:17.877: I/dalvikvm(5225): | schedstat=( 0 0 0 ) utm=343 stm=24 core=1
09-24 20:34:17.877: I/dalvikvm(5225): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
09-24 20:34:17.877: I/dalvikvm(5225): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
09-24 20:34:17.877: I/dalvikvm(5225): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
09-24 20:34:17.877: I/dalvikvm(5225): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
09-24 20:34:17.877: I/dalvikvm(5225): at android.content.res.Resources.loadDrawable(Resources.java:1930)
09-24 20:34:17.877: I/dalvikvm(5225): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-24 20:34:17.877: I/dalvikvm(5225): at android.widget.ImageView.<init>(ImageView.java:120)
09-24 20:34:17.877: I/dalvikvm(5225): at android.widget.ImageView.<init>(ImageView.java:110)
09-24 20:34:17.877: I/dalvikvm(5225): at java.lang.reflect.Constructor.constructNative(Native Method)
09-24 20:34:17.877: I/dalvikvm(5225): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
09-24 20:34:17.877: I/dalvikvm(5225): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-24 20:34:17.877: I/dalvikvm(5225): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-24 20:34:17.877: I/dalvikvm(5225): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.Activity.setContentView(Activity.java:1867)
09-24 20:34:17.877: I/dalvikvm(5225): at ab.wallpapers.hd.Wallpapers.onCreate(Wallpapers.java:13)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.Activity.performCreate(Activity.java:5008)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-24 20:34:17.877: I/dalvikvm(5225): at android.os.Handler.dispatchMessage(Handler.java:99)
09-24 20:34:17.877: I/dalvikvm(5225): at android.os.Looper.loop(Looper.java:137)
09-24 20:34:17.877: I/dalvikvm(5225): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-24 20:34:17.877: I/dalvikvm(5225): at java.lang.reflect.Method.invokeNative(Native Method)
09-24 20:34:17.877: I/dalvikvm(5225): at java.lang.reflect.Method.invoke(Method.java:511)
09-24 20:34:17.877: I/dalvikvm(5225): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-24 20:34:17.877: I/dalvikvm(5225): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-24 20:34:17.877: I/dalvikvm(5225): at dalvik.system.NativeStart.main(Native Method)
09-24 20:34:17.877: A/libc(5225): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 5225 (b.wallpapers.hd)
推荐答案
尽量减小你设置为 ImageViews 源的图像的大小.问题是 Android 无法分配足够的内存来保存 ImageView 的可绘制对象.因此,首先分析哪个图像太大,并记住这里重要的是解压后图像的大小(基本上,高度 * 宽度 * 4 字节).
Try to reduce the size of the images you set as the source of the ImageViews. The problem is that Android can't allocate enough memory to hold the drawable of your ImageViews. So Start by analysing which image is too big and remember that it is the size of the decrompressed image that matters here (basically, height * width * 4 bytes).
这篇关于致命信号 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!