gpt4 book ai didi

java - Android 应用程序不断崩溃,致命异常

转载 作者:行者123 更新时间:2023-12-01 13:16:15 44 4
gpt4 key购买 nike

嗨,我正在使用 webview 为 Android 应用程序制作一个简单的浏览器。

这是我的浏览器类

package com.example.projecta;



import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;


public class Browser extends Activity implements OnClickListener {

EditText addbar;
WebView appbrow;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.easybrowser);

appbrow = (WebView) findViewById(R.layout.easybrowser);
appbrow.loadUrl("http://www.google.com");


}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

}


}

这是我的 list 。

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

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

<uses-permission android:name="android.permisson.CAMERA" />
<uses-permission android:maxSdkVersion="19"

android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.INTERNET"

android:maxSdkVersion="19"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.projecta.Startbackground"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<activity
android:name="com.example.projecta.Menu"
android:label="@string/app_name" >

<intent-filter>
<action android:name="android.intent.action.MENU" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.projecta.Camera"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>

<activity
android:name="com.example.projecta.Browser"
android:label="@string/app_name" >

</activity>

</application>

</manifest>

这是我的日志

03-16 15:59:36.234: D/dalvikvm(1287): GC_FOR_ALLOC freed 53K, 5% free 3033K/3160K, paused 23ms, total 25ms
03-16 15:59:36.244: I/dalvikvm-heap(1287): Grow heap (frag case) to 4.650MB for 1705616-byte allocation
03-16 15:59:36.294: D/dalvikvm(1287): GC_FOR_ALLOC freed 2K, 3% free 4696K/4828K, paused 40ms, total 40ms
03-16 15:59:36.524: E/MediaPlayer(1287): Should have subtitle controller already set
03-16 15:59:36.764: D/gralloc_goldfish(1287): Emulator without GPU emulation detected.
03-16 15:59:41.874: D/dalvikvm(1287): GC_FOR_ALLOC freed 13K, 2% free 4906K/4988K, paused 26ms, total 27ms
03-16 15:59:41.874: I/dalvikvm-heap(1287): Grow heap (frag case) to 5.928MB for 1127536-byte allocation
03-16 15:59:41.994: D/dalvikvm(1287): GC_FOR_ALLOC freed 1K, 2% free 6005K/6092K, paused 110ms, total 110ms
03-16 15:59:47.184: I/Choreographer(1287): Skipped 85 frames! The application may be doing too much work on its main thread.
03-16 15:59:48.924: V/WebViewChromium(1287): Binding Chromium to the background looper Looper{b1d9afa0}
03-16 15:59:48.934: I/chromium(1287): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
03-16 15:59:48.944: I/BrowserProcessMain(1287): Initializing chromium process, renderers=0
03-16 15:59:49.064: E/chromium(1287): [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
03-16 15:59:49.064: E/chromium(1287): [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
03-16 15:59:49.064: E/chromium(1287): [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
03-16 15:59:49.074: E/chromium(1287): [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
03-16 15:59:49.074: E/chromium(1287): [ERROR:gpu_info_collector.cc(86)] gfx::GLSurface::InitializeOneOff() failed
03-16 15:59:49.154: W/chromium(1287): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
03-16 15:59:49.314: D/AndroidRuntime(1287): Shutting down VM
03-16 15:59:49.314: W/dalvikvm(1287): threadid=1: thread exiting with uncaught exception (group=0xb1ac2b90)
03-16 15:59:49.334: E/AndroidRuntime(1287): FATAL EXCEPTION: main
03-16 15:59:49.334: E/AndroidRuntime(1287): Process: com.example.projecta, PID: 1287
03-16 15:59:49.334: E/AndroidRuntime(1287): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projecta/com.example.projecta.Browser}: java.lang.NullPointerException
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.ActivityThread.access$700(ActivityThread.java:135)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.os.Handler.dispatchMessage(Handler.java:102)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.os.Looper.loop(Looper.java:137)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.ActivityThread.main(ActivityThread.java:4998)
03-16 15:59:49.334: E/AndroidRuntime(1287): at java.lang.reflect.Method.invokeNative(Native Method)
03-16 15:59:49.334: E/AndroidRuntime(1287): at java.lang.reflect.Method.invoke(Method.java:515)
03-16 15:59:49.334: E/AndroidRuntime(1287): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-16 15:59:49.334: E/AndroidRuntime(1287): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
03-16 15:59:49.334: E/AndroidRuntime(1287): at dalvik.system.NativeStart.main(Native Method)
03-16 15:59:49.334: E/AndroidRuntime(1287): Caused by: java.lang.NullPointerException
03-16 15:59:49.334: E/AndroidRuntime(1287): at com.example.projecta.Browser.onCreate(Browser.java:26)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.Activity.performCreate(Activity.java:5243)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-16 15:59:49.334: E/AndroidRuntime(1287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
03-16 15:59:49.334: E/AndroidRuntime(1287): ... 11 more

请帮忙。这个应用程序有一个菜单。相机、浏览器

应用程序的相机部分工作正常,但当我单击菜单中的浏览器时,它停止工作。谢谢

最佳答案

appbrow = (WebView) findViewById(R.layout.easybrowser);

应该是

appbrow = (WebView) findViewById(R.id.idWebViewInLayout);

关于java - Android 应用程序不断崩溃,致命异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22442280/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com