Skip to main content

Android app crashes on load - classNotFoundException



This has been driving me mad for a couple of days :)





IDEA is my weapon of choice. During an editing session of inconsequential changes (or so I thought) of adjusting layouts, nudging buttons a few pixels left to line up etc I compiled and ran the project. I got a ClassNotFoundException when my app starts. It is thrown by java.lang.Bootloader. I put a breakpoint on the call to the Bootloader and can see that the offending class is my main application class. Here's how it looks:







public class Rands extends Application{



public static SharedPreferences preferences;



private static ArrayList<Favourite> favourites;



private static Rands instance;



public Rands(){

instance = this;

}







and in the manifest:







<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="rands.mycompany.com"

android:installLocation="preferExternal"

android:versionCode="8"

android:versionName="0.8">

<uses-sdk android:minSdkVersion="8" />



<uses-permission android:name="android.permission.VIBRATE" />



<application android:name="rands.mycompany.com.Rands"

android:icon="@drawable/icon"

android:label="@string/app_name">



<activity android:name="rands.mycompany.com.RandsMainActivity"

android:theme="@android:style/Theme.Translucent.NoTitleBar"

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="rands.mycompany.com.MainMenuActivity"

android:theme="@android:style/Theme.Translucent.NoTitleBar"

android:label="MainMenuActivity"/>







This is where things get funky. There is NOTHING of relevance in logcat. I see the app copying, installing and starting then I get the exception. The exception occurs before the constructor on my application class is called. If I load the project in Eclipse, it works fine. I load in back into IDEA and I get the exception. I have two phones, a Desire with 2.3 and a Tmobile Pulse (Huawei) with 2.2. It happens on both phones and in the emulator. If I run the app outside the IDE (i.e. from the launcher) it runs fine.





I make these assumptions:





  1. As there is nothing in logcat, it smells like a platform bug



  2. As the project works fine in Eclipse, I'm assuming that my manifest and application class are fine.







I've also tried







<application android:name=".Rands"







Any clues?





Cheers


Comments

  1. you have already specify the package name in menifest tag so don't redeclare it in activity tag, below code will work for menifest.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="rands.mycompany.com"
    android:installLocation="preferExternal"
    android:versionCode="8"
    android:versionName="0.8">
    <uses-sdk android:minSdkVersion="8" />

    <uses-permission android:name="android.permission.VIBRATE" />

    <application android:name="rands.mycompany.com.Rands"
    android:icon="@drawable/icon"
    android:label="@string/app_name">

    <activity android:name=".Rands"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    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=".MainMenuActivity"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    android:label="MainMenuActivity"/>

    ReplyDelete
  2. Your Application and Activity objects are both named as "rands.mycompany.com.Rands" maybe that's the problem?

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 3 Final Exam => latest version

1 . Which security protocol or measure would provide the greatest protection for a wireless LAN? WPA2 cloaking SSIDs shared WEP key MAC address filtering   2 . Refer to the exhibit. All trunk links are operational and all VLANs are allowed on all trunk links. An ARP request is sent by computer 5. Which device or devices will receive this message? only computer 4 computer 3 and RTR-A computer 4 and RTR-A computer 1, computer 2, computer 4, and RTR-A computer 1, computer 2, computer 3, computer 4, and RTR-A all of the computers and the router   3 . Refer to the exhibit. Hosts A and B, connected to hub HB1, attempt to transmit a frame at the same time but a collision occurs. Which hosts will receive the collision jamming signal? only hosts A and B only hosts A, B, and C only hosts A, B, C, and D only hosts A, B, C, and E   4 . Refer to the exhibit. Router RA receives a packet with a source address of 192.168.1.65 and a destination address of 192.168.1.161...