Webview android app forcecloses

时间:2012-11-05 08:26:26

标签: android

你好我所有的Android开发新手我得到以下错误任何帮助吗? 提前谢谢

package com.example.gossipmate.mobi;
import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Gossipmate extends Activity 
{
    final Activity activity = this;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.activity_gossip_mate);
        final WebView webView = (WebView) findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {
                activity.setTitle("Loading");
                activity.setProgress(progress * 100);

                if (progress == 100)
                    activity.setTitle(R.string.app_name);
            }

        });
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onReceivedError(WebView view, int errorCode,
                    String description, String failingUrl) {
                // Handle the error
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

        });

        webView.loadUrl("http://www.gossipmate.x10.bz");

    }}

以上是我的应用程序的代码,错误如下所示

11-05 13:34:06.329: W/dalvikvm(595): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-05 13:34:06.429: E/AndroidRuntime(595): FATAL EXCEPTION: main
11-05 13:34:06.429: E/AndroidRuntime(595): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.gossipmate.mobi/com.example.gossipmate.mobi.GossipMate}: java.lang.ClassNotFoundException: com.example.gossipmate.mobi.GossipMate in loader dalvik.system.PathClassLoader[/data/app/com.example.gossipmate.mobi-1.apk]
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.os.Looper.loop(Looper.java:123)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.ActivityThread.main(ActivityThread.java:3683)
11-05 13:34:06.429: E/AndroidRuntime(595):  at java.lang.reflect.Method.invokeNative(Native Method)
11-05 13:34:06.429: E/AndroidRuntime(595):  at java.lang.reflect.Method.invoke(Method.java:507)
11-05 13:34:06.429: E/AndroidRuntime(595):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-05 13:34:06.429: E/AndroidRuntime(595):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-05 13:34:06.429: E/AndroidRuntime(595):  at dalvik.system.NativeStart.main(Native Method)
11-05 13:34:06.429: E/AndroidRuntime(595): Caused by: java.lang.ClassNotFoundException: com.example.gossipmate.mobi.GossipMate in loader dalvik.system.PathClassLoader[/data/app/com.example.gossipmate.mobi-1.apk]
11-05 13:34:06.429: E/AndroidRuntime(595):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-05 13:34:06.429: E/AndroidRuntime(595):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-05 13:34:06.429: E/AndroidRuntime(595):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-05 13:34:06.429: E/AndroidRuntime(595):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-05 13:34:06.429: E/AndroidRuntime(595):  ... 11 more
11-05 13:34:06.539: W/ActivityManager(61):   Force finishing activity com.example.gossipmate.mobi/.GossipMate
11-05 13:34:07.109: W/ActivityManager(61): Activity pause timeout for HistoryRecord{406d08c8 com.example.gossipmate.mobi/.GossipMate}

清单文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gossipmate.mobi"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="15" />

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".GossipMate"
        android:label="@string/title_activity_gossip_mate" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

以上是我使用的清单代码我相信我已经注册了活动

使用m更改M并启动新项目后,应用程序正在运行,没有任何问题。

2 个答案:

答案 0 :(得分:1)

检查Manifest文件中活动名称的拼写,错误。  它应该是Gossipmate而不是GossipMate

<强>更新

尝试将此行放入您的清单android:name="com.example.gossipmate.mobi.Gossipmate"而不是android:name=".GossipMate"

答案 1 :(得分:0)

AndroidManifest.xml.中,活动的名称为android:name=".GossipMate",其中m的配偶为大写字母,活动中的位置为Gossipmate !!!

检查java.lang.RuntimeException: Unable to instantiate activity ComponentInfo