6

I've seen the following error a few times during the development cycle and now I just received an error report. I have no idea what's causing this. After reading similar questions on this site regarding this issue, I double checked my AndroidManifest and everything looks fine to me. Any ideas on what could possibly be causing this exception?

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.jerrellmardis.ridecta/com.jerrellmardis.ridecta.ui.StopTimesActivity}: java.lang.ClassNotFoundException: com.jerrellmardis.ridecta.ui.StopTimesActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.jerrellmardis.ridecta.ui.StopTimesActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
... 11 more

Another thing to note is that I'm using the android-support-v4-googlemaps lib found at https://github.com/petedoyle/android-support-v4-googlemaps which allows me to embed a MapView in a Fragment (along with the ActionBarSherlock lib). This exception seems like a dependency issue and I'm not sure if it's related to how I'm using the above mentioned libs.

Here's the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jerrellmardis.ridecta"
    android:installLocation="internalOnly"
    android:versionCode="11"
    android:versionName="1.0.2">
    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="16"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.android.vending.BILLING"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <application
        android:name=".RideCtaApplication"
        android:allowBackup="true"
        android:backupAgent=".backup.RideCtaBackupAgentHelper"
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:logo="@drawable/logo">
        <uses-library android:name="com.google.android.maps"/>
        <activity
            android:name=".ui.HomeActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta.LogoOnly">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.BusDirectionsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.StopsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.StopTimesActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta.Split"
            android:uiOptions="splitActionBarWhenNarrow"/>
        <activity
            android:name=".ui.TrainDirectionsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.LiveMapActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta.Transparent"/>
        <activity
            android:name=".ui.ServiceAlertsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.SearchActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/Theme.RideCta">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable"/>
        </activity>
        <activity
            android:name=".ui.PreferenceActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.Preference"/>
        <activity
            android:name=".ui.LegacyPreferenceActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.Preference"/>
        <activity
            android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
        <receiver android:name=".receiver.ReminderAlarmReceiver"/>
        <receiver android:name=".receiver.ReminderBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
        <receiver android:name="net.robotmedia.billing.BillingReceiver">
            <intent-filter>
                <action android:name="com.android.vending.billing.IN_APP_NOTIFY"/>
                <action android:name="com.android.vending.billing.RESPONSE_CODE"/>
                <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED"/>
            </intent-filter>
        </receiver>
        <service android:name=".service.ReminderService"/>
        <service android:name="net.robotmedia.billing.BillingService"/>
        <meta-data
            android:name="android.app.default_searchable"
            android:value=".ui.SearchActivity"/>
        <meta-data
            android:name="com.google.android.backup.api_key"
            android:value="<REMOVED>"/>
        <provider
            android:name=".provider.SearchProvider"
            android:authorities="com.jerrellmardis.ridecta.provider.SearchProvider"/>
    </application>
</manifest>
9
  • 1
    chck whether you have mentioned correct class name in android manifest Nov 7, 2012 at 6:58
  • 2
    Please post your (partial) manifest XML. Also, where is this class located? In a library project or the same project?
    – JScoobyCed
    Nov 7, 2012 at 7:00
  • Have you tried looking at the theme on your activity? android:theme="@style/Theme.RideCta.Split" android:uiOptions="splitActionBarWhenNarrow"
    – Radu Dan
    Nov 15, 2012 at 16:05
  • @Radu how would a theme cause the issue?
    – oracleicom
    Nov 15, 2012 at 16:24
  • Did the same people ever get the app to work, or was it random failures? Nov 16, 2012 at 16:57

9 Answers 9

5

Right click on your project folder => Properties => Java Build Path => Order and Export => check the box "Android Private Libraries" if not checked. Make a clean. And it works !

2

System is not able to find your class file. So either there's something wrong with your class name specification in manifest file or your class exists in some different package as you could have specified.

Try cleaning and rebuilding your code. Some times we need to do cleaning on making updates to the code.

Also no one could find the error by just reading your logcat. so better post your manifest file and all the classes names.

1

Add activity to manifest file as..

<activity android:name=".FSRRemarks" >
        </activity>

And if you have already added it, try to clean build your project and then run

1

In my experience, if you are seeing weird exceptions related to not being able to load resources or classes which you absolutely know are there, the problem could be related to pushing the activity too close to its memory limit. Having worked on a few memory-hungry apps, I can say that I've seen many exceptions reported "in the wild" having to do with not finding resources which I know were correctly included in the production build.

Generally speaking, in these cases the stacktraces never are 100% identical, so if you are consistently seeing the same missing classes, it is likely an error with your build or project configuration. Doing a full rebuild (as others have also suggested) could help.

Otherwise, I would suggest using a service like Crittercism to get more accurate information about the device right before the crashes occur.

1

Please follow the steps:-

1> Remove the external jars from the reference library. Don't add them here again.

2> Create another folder "libs" in your project.

3> Copy and paste your jars in the "libs" folder.

4> Clean and re-run the app.

Hope it works.

2
  • I currently have a libs folder with all my external jars that are not Android libraries.
    – oracleicom
    Nov 15, 2012 at 16:25
  • Check whether these jars are also in reference library folder.
    – Code Word
    Nov 16, 2012 at 6:46
0

If you have already added the activity to AndroidManifest, and the activity does exist in your project, I suggest you just clean and rebuild then try again. But I have meet another strange proble, that is apk file build by Ecplise will crash and report proble "ClassNotFoundException with applicaion", while, apk file build by ant can run normally, with no problem.

So maybe you can also try to use ant to build it, by command "android update project -p .".

0

To avoid errors like these, just follow these steps whenever you need to create a new class;

  1. Double click on AndroidManifest.xml in the package explorer.
  2. Click on the "Application" tab of the manifest editor
  3. Click on "Add.." under the "Application Nodes" heading (bottom left of the screen)
  4. Choose Activity from the list in the dialog that pops up (if you have the option, you want to create a new top-level element)
  5. Click on the "Name*" link under the "Attributes for" header (bottom right of the window) to create a class for the new activity.
  6. When you click Finish from the new class dialog, it'll take you to your new activity class so you can start coding.

Just copy your code from your activity, delete the file and recreate it like this and all your configuration related problems wil be taken care of.

0

Where did you copy the android-support-v4-googlemaps.jar file? inside actionbarsherlock/library/libs ? or inside your_app/libs?

Double check that you are not including two different versions of the support libraries ( one with maps and the other without them )

0

It looks like I've fixed the issue by not using the android-support-v4-googlemaps lib. I changed my app to use an ImageView of Map in a Fragment and then a plain old MapActivity once the user clicks on the Map image. Since doing this I haven't noticed any RuntimeExceptions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.