James Mitchee
James Mitchee

Reputation: 143

eclipse android app error

I am having problem on running the app in eclipse I cant figure out whats the problem. as there is no error in the project files. I have reinstalled the eclipse, and after it i am getting problems. java file

package com.goby.bus;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class GobybusActivity extends Activity {
    WebView mWebView;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("file:///android_asset/index.html");
        mWebView.setWebViewClient(new mWebViewClient());
        mWebView.setBackgroundColor(Color.WHITE);
    }



    private class mWebViewClient extends WebViewClient {        

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

}

the log file:

04-22 11:21:54.508: D/AndroidRuntime(623): Shutting down VM
04-22 11:21:54.528: W/dalvikvm(623): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-22 11:21:54.618: E/AndroidRuntime(623): FATAL EXCEPTION: main
04-22 11:21:54.618: E/AndroidRuntime(623): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.goby.bus/com.goby.bus.MainActivity}: java.lang.ClassNotFoundException: com.goby.bus.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.goby.bus-1.apk]
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.os.Looper.loop(Looper.java:123)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-22 11:21:54.618: E/AndroidRuntime(623):  at java.lang.reflect.Method.invokeNative(Native Method)
04-22 11:21:54.618: E/AndroidRuntime(623):  at java.lang.reflect.Method.invoke(Method.java:521)
04-22 11:21:54.618: E/AndroidRuntime(623):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-22 11:21:54.618: E/AndroidRuntime(623):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-22 11:21:54.618: E/AndroidRuntime(623):  at dalvik.system.NativeStart.main(Native Method)
04-22 11:21:54.618: E/AndroidRuntime(623): Caused by: java.lang.ClassNotFoundException: com.goby.bus.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.goby.bus-1.apk]
04-22 11:21:54.618: E/AndroidRuntime(623):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-22 11:21:54.618: E/AndroidRuntime(623):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-22 11:21:54.618: E/AndroidRuntime(623):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-22 11:21:54.618: E/AndroidRuntime(623):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)

All replies are welcome...

Upvotes: 0

Views: 321

Answers (2)

Kevin Cuperus
Kevin Cuperus

Reputation: 1

Move

WebView mWebView;

above

mWebView = (WebView) findViewById(R.id.webview);

Upvotes: 0

MByD
MByD

Reputation: 137272

Seems like the activity name specified in the XML doesn't match your class name, as indicated in this line:

04-22 11:21:54.618: E/AndroidRuntime(623): Caused by: java.lang.ClassNotFoundException: com.goby.bus.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.goby.bus-1.apk]

In your android manifest XML, change

<activity android:name=".MainActivity "  ... >

to

<activity android:name=".GobybusActivity"  ... >

Upvotes: 3

Related Questions