我讀過上百問題的同一類別,但沒有幫助。我有一個工作的應用程序,然後重構包名,並編譯並運行。一個星期後,我回來工作,並在啓動時得到ClassNotFoundException。更糟糕的是,如果我簽出回購協議中的前一個提交(任何重構之前的一個工作),那麼該項目在啓動時會引發相同的錯誤(除了使用不同的軟件包名稱)。無法實例化服務:ClassNotFoundException的
我用盡了一切我能想到的,我不知道如何追蹤問題了。我也做了明顯的事情:清理項目,將其全部刪除,然後重新添加它,新的設備上運行...
我不知道什麼代碼將有助於調試,但這裏的宣言我的清單和logcat輸出。如果別的東西可能有用,請告訴我。我真的迷失在這裏。
崩潰:
E/AndroidRuntime( 515): FATAL EXCEPTION: main
E/AndroidRuntime( 515): java.lang.RuntimeException: Unable to instantiate service
co.mosic.mosic.CommunicationService: java.lang.ClassNotFoundException: co.mosic.mosic.CommunicationService
E/AndroidRuntime( 515): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2237)
E/AndroidRuntime( 515): at android.app.ActivityThread.access$1600(ActivityThread.java:123)
E/AndroidRuntime( 515): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
E/AndroidRuntime( 515): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 515): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 515): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 515): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 515): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 515): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 515): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 515): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 515): Caused by: java.lang.ClassNotFoundException: co.mosic.mosic.CommunicationService
E/AndroidRuntime( 515): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime( 515): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 515): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 515): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2234)
E/AndroidRuntime( 515): ... 10 more
清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.mosic.mosic"
android:versionCode="1"
android:versionName="1.0" >
...
<service
android:name=".CommunicationService" >
<intent-filter>
<action android:name="co.mosic.mosic.MStcServiceInet" />
</intent-filter>
</service>
它已修復!我真的不知道如何。最後一件事是修正它將我的「lib」文件夾改爲「libs」,但之前它被命名爲「lib」。我最近也更改了我的Java編譯器,但不記得確切的時間表。也許它對jar的文件夾名稱更挑剔?真的,我只花了幾個小時,周圍的重構粉碎,清洗,重建...... – jarvisteve
是的,我想'libs'是'ant'腳本正確的名稱。 – 2012-05-15 09:49:18