eclipse Android 应用程序错误 - 不幸的是您的应用程序已停止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32367999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android app error- unfortunately your app has stopped
提问by Avini Sasadari Wanigasinghe
I am using eclipse for android app development. When I run my code using emulator, it says unfortunately your app has stopped. In the log cat, it says "Low memory killer". How to resolve this problem? Can anyone answer please..
我正在使用 eclipse 进行 android 应用程序开发。当我使用模拟器运行我的代码时,它说不幸的是您的应用程序已停止。在日志猫中,它说“低内存杀手”。如何解决这个问题?请问有谁可以解答。。
Here are the stack trace which appear when my app is loading..
这是我的应用程序加载时出现的堆栈跟踪..
09-03 15:54:39.109: E/SysUtils(1892): ApplicationContext is null in ApplicationStatus
09-03 15:54:40.027: E/libEGL(1892): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-03 15:54:40.027: E/libEGL(1892): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-03 15:54:40.027: E/chromium(1892): [ERROR:gl_surface_egl.cc(327)] No suitable EGL configs found.
09-03 15:54:40.027: E/chromium(1892): [ERROR:gl_surface_android.cc(23)] GLSurfaceEGL::InitializeOneOff failed.
09-03 15:54:40.027: E/chromium(1892): [ERROR:browser_main_loop.cc(698)] GLSurface::InitializeOneOff failed
09-03 15:54:40.396: E/DataReductionProxySettingListener(1892): No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
09-03 15:54:44.051: A/chromium(1892): [FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
09-03 15:54:44.051: A/chromium(1892): --------- beginning of crash
09-03 15:54:44.052: A/libc(1892): Fatal signal 6 (SIGABRT), code -6 in tid 1972 (GpuThread)
09-03 15:57:17.517: E/SysUtils(2115): ApplicationContext is null in ApplicationStatus
09-03 15:57:17.598: E/libEGL(2115): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-03 15:57:17.598: E/libEGL(2115): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
09-03 15:57:17.598: E/chromium(2115): [ERROR:gl_surface_egl.cc(327)] No suitable EGL configs found.
09-03 15:57:17.598: E/chromium(2115): [ERROR:gl_surface_android.cc(23)] GLSurfaceEGL::InitializeOneOff failed.
09-03 15:57:17.598: E/chromium(2115): [ERROR:browser_main_loop.cc(698)] GLSurface::InitializeOneOff failed
09-03 15:57:17.674: E/DataReductionProxySettingListener(2115): No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
09-03 15:57:18.141: A/chromium(2115): [FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
09-03 15:57:18.141: A/libc(2115): Fatal signal 6 (SIGABRT), code -6 in tid 2155 (GpuThread)
Main activity file
主要活动文件
package com.example.login4;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView ourBrow = (WebView) findViewById(R.id.wvBrowser);
ourBrow.loadUrl("http://www.000webhost.com//");
}
}
XML file
XML文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.login4.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/wvBrowser"/>
</RelativeLayout>
回答by Satees Kumar Reddy
This is because of your images have heavy memory. In order to avoid this error, move your images to xxhdpi folder.
这是因为您的图像内存很大。为了避免此错误,请将您的图像移动到 xxhdpi 文件夹。
回答by Jos
In onCreate, the layout is not loaded yet, so
在onCreate中,布局还没有加载,所以
findViewById(R.id.wvBrowser)
returns null. Then in the next line
返回空值。然后在下一行
ourBrow.loadUrl("http://www.000webhost.com//");
will result in a NullPointerException. Solution is to move the code to the onStart method of the Activity:
将导致 NullPointerException。解决方法是将代码移到Activity的onStart方法中:
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.activity_main);
WebView ourBrow = (WebView) findViewById(R.id.wvBrowser);
ourBrow.loadUrl("http://www.000webhost.com//");
}
回答by carlosJ
Looking at the first error that occurred "No suitable EGL configs found". I solved this issue by ticking 'Use Host GPU' in the AVD. Also make sure that the Internet permission is added to the AndroidManifest.xml
查看发生的第一个错误“找不到合适的 EGL 配置”。我通过在 AVD 中勾选“使用主机 GPU”解决了这个问题。还要确保将 Internet 权限添加到 AndroidManifest.xml