Suresh Kumar
Suresh Kumar

Reputation: 227

Webview android app forcecloses

hello all i am new to android development i am getting this following errors any help please? thanks in advance

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");

    }}

THe above is the code for my app and the errors are shown below

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 FILE

<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>

the above is the manifest code i am using i am sure i have registered the activity

The app is working now with no problems after i changed the M with m and started a new project.

Upvotes: 0

Views: 252

Answers (2)

Antrromet
Antrromet

Reputation: 15414

Check the spelling of your Activity name in the Manifest file, its wrong. It should be Gossipmate instead of GossipMate.

UPDATE

Try putting this line in your manifest android:name="com.example.gossipmate.mobi.Gossipmate" instead of android:name=".GossipMate"

Upvotes: 1

Nermeen
Nermeen

Reputation: 15973

In your AndroidManifest.xml. the name of the activity is android:name=".GossipMate" with m of mate is capital letter, where in the activity it's Gossipmate !!!

check java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

Upvotes: 0

Related Questions