我正在使用eclipse进行Android应用程序开发。当我使用模拟器运行我的代码时,它说不幸的是你的应用已停止。在日志猫中,它说“低记忆杀手”。如何解决这个问题?任何人都可以回答..
以下是我的应用加载时出现的堆栈跟踪..
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)
主要活动文件
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文件
<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>
答案 0 :(得分:2)
这是因为你的图像有很重的记忆。为避免此错误,请将图像移动到xxhdpi文件夹。
答案 1 :(得分:0)
在onCreate中,尚未加载布局,所以
findViewById(R.id.wvBrowser)
返回null。然后在下一行
ourBrow.loadUrl("http://www.000webhost.com//");
将导致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//");
}
答案 2 :(得分:0)
查看发生的第一个错误“找不到合适的EGL配置”。 我通过勾选AVD中的“使用主机GPU”解决了这个问题。还要确保将Internet权限添加到AndroidManifest.xml