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

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

ArtVandelay
  • 97
  • 3
  • 11

3 Answers3

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.

SKK
  • 5,261
  • 3
  • 27
  • 39
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.

Mit Bhatt
  • 1,605
  • 2
  • 13
  • 24
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.

dumbfingers
  • 7,001
  • 5
  • 54
  • 80