我重新安裝了ADT Bundle,因爲在更新eclipse之後我遇到了一些問題。Android:ClassNotFoundException
現在,我得到下面的異常,當我想測試我的應用程序:
06-05 10:33:35.770: E/AndroidRuntime(17751): FATAL EXCEPTION: main
06-05 10:33:35.770: E/AndroidRuntime(17751): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{foo.bar/foo.bar.TabsFragmentActivity}: java.lang.ClassNotFoundException: foo.bar.TabsFragmentActivity in loader dalvik.system.PathClassLoader[/data/app/foo.bar-2.apk]
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1670)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.os.Handler.dispatchMessage(Handler.java:99)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.os.Looper.loop(Looper.java:130)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.ActivityThread.main(ActivityThread.java:3695)
06-05 10:33:35.770: E/AndroidRuntime(17751): at java.lang.reflect.Method.invokeNative(Native Method)
06-05 10:33:35.770: E/AndroidRuntime(17751): at java.lang.reflect.Method.invoke(Method.java:507)
06-05 10:33:35.770: E/AndroidRuntime(17751): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
06-05 10:33:35.770: E/AndroidRuntime(17751): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
06-05 10:33:35.770: E/AndroidRuntime(17751): at dalvik.system.NativeStart.main(Native Method)
06-05 10:33:35.770: E/AndroidRuntime(17751): Caused by: java.lang.ClassNotFoundException: foo.bar.TabsFragmentActivity in loader dalvik.system.PathClassLoader[/data/app/foo.bar-2.apk]
06-05 10:33:35.770: E/AndroidRuntime(17751): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-05 10:33:35.770: E/AndroidRuntime(17751): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-05 10:33:35.770: E/AndroidRuntime(17751): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-05 10:33:35.770: E/AndroidRuntime(17751): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
06-05 10:33:35.770: E/AndroidRuntime(17751): ... 11 more
這裏的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foo.bar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="foo.bar.ui.tabs.TabsFragmentActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="foo.bar.ui.activities.EditActivity"
android:parentActivityName="foo.bar.ui.tabs.TabsFragmentActivity"
android:windowSoftInputMode="stateHidden">
</activity>
<activity
android:name="foo.bar.ui.activities.LocationActivity"
android:label="Select a location"
android:parentActivityName="foo.bar.ui.tabs.TabsFragmentActivity" >
</activity>
<activity
android:name="foo.bar.ui.activities.DeleteLocationsActivity"
android:label="Delete locations"
android:parentActivityName="foo.bar.ui.activities.LocationActivity" >
</activity>
<activity
android:name="foo.bar.ui.activities.ShowLocationActivity"
android:parentActivityName="foo.bar.ui.activities.LocationActivity" >
</activity>
<activity
android:name="foo.bar.ui.activities.ShowSnapshotActivity"
android:parentActivityName="foo.bar.ui.activities.ShowLocationActivity" >
</activity>
<service
android:name="foo.bar.service.SnapshotService" >
</service>
</application>
</manifest>
我認爲它已經做了一些做的包裝,即。它看着活動的錯誤地點,但我不知道如何解決它。
我試着清理項目並在清單中只使用「.activityname」,這兩個都不起作用。
編輯:我現在通過將TabsFragmentActivity移動到標準包,然後返回到ui.tabs。
不知道爲什麼這工作雖然。
感謝您的幫助
你可以發佈活動代碼和項目包結構嗎? –