1

I reinstalled the ADT Bundle, because I had some problems after updating eclipse.

Now I get the following exception, when I want to test my app:

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.access1500ドル(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

Here's the manifest:

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

I think it has done something to do with the packaging, ie. it looks at the wrong place for the activity, but I don't know how to fix it.

I tried cleaning the project and using only ".activityname" in the manifest, which both didn't work.

EDIT: I got it to work now by moving the TabsFragmentActivity to the standard package and then back to ui.tabs.

Not sure why this worked though.

Thanks for all your help

asked Jun 5, 2013 at 8:49
1
  • could you post the activity code and project package structure? Commented Jun 5, 2013 at 8:51

3 Answers 3

3

from the logcat:

java.lang.ClassNotFoundException: foo.bar.TabsFragmentActivity

And from your manifest:

android:name="foo.bar.ui.tabs.TabsFragmentActivity"

So, my suggestion is to:

  • move TabsFragmentActivity to foo.bar.ui.tabs
  • or change android:name="foo.bar.ui.tabs.TabsFragmentActivity" to android:name="foo.bar.TabsFragmentActivity"

Note:

If you recently updated your ADT plugin then:

In Eclipse right click on project -> properties -> java Build Path -> Order & Export and check Android Private Libraries(Android Support Library previously) for your project and also in all other library projects you are using. Clean and Build again.

Hope this helps.

answered Jun 5, 2013 at 8:53
Sign up to request clarification or add additional context in comments.

3 Comments

TabsFragmentActivity already is in the package foo.bar.ui.tabs
It occurs as soon as I start the app. I don't think there is any code involved, because it worked before the update
Check my Updated answer. Hope it helps.
0

I thought you have rename package name from Refactor.At that time you asked for some options like

  • Update References
  • rename subpackages
  • update textual occurence.....
  • updatefully Java textfiles....

So you have to make changes as you want from here.,, Now do one thing,again make your Package name as Previous if you remember it,and thn again Refactor it.. MAy be this will help.

Or Use Android Tools--->Rename Application PAckage.

answered Jun 5, 2013 at 8:55

1 Comment

0

I encounter this error only when I import projects that I cloned from Github, and my solution is like this:

  1. Right-click your project in Eclipse, select Properties

  2. Select Java Build Path in the left then select Order and Export tab

  3. Tick

    • Android 4.2(or any other version that you are using)
    • Android Private Libraries
    • Android Dependencies
  4. Press OK then do a project clean

These names above may vary, this works every time when I got the ClassNotFound exception.

answered Jun 5, 2013 at 9:18

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.