2012-04-22 51 views
0

我在eclipse中運行應用程序時遇到問題我無法弄清楚最新的問題。因爲項目文件中沒有錯誤。 我已經重新安裝了日食,並且在它出現問題之後。 Java文件eclipse android應用程序錯誤

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

} 

日誌文件:

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) 

所有答覆,歡迎...

+0

您能向我們展示您的Manifest文件嗎? – 2012-04-22 06:03:02

回答

3

好像在XML不符合您的類名指定的活動名稱,如

11月4日至22日:21:54.618:在這個線表示E/AndroidRuntime(623): JA:致va.lang.ClassNotFoundException:com.goby.bus.MainActivity裝載機 dalvik.system.PathClassLoader [/data/app/com.goby.bus-1.apk]

在你的Android清單XML,變化

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

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

darn ....感謝您的幫助! – 2012-04-22 06:05:15

0

移動

WebView mWebView; 

以上

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