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 1 Final Exam 2011 latest (hot hot hot)

  Hi! I have been posted content of ccna1 final exam (latest and only question.) I will post the answer and insert image on sunday. If you care, please subscribe your email an become a first person have full test content. Subcribe now  Some question  have not content because this question have images content. So that can you wait for me? SUNDAY 1. A user sees the command prompt: Router(config-if)# . What task can be performed at this mode? Reload the device. Perform basic tests. Configure individual interfaces. Configure individual terminal lines. 2. Refer to the exhibit. Host A attempts to establish a TCP/IP session with host C. During this attempt, a frame was captured with the source MAC address 0050.7320.D632 and the destination MAC address 0030.8517.44C4. The packet inside the captured frame has an IP source address 192.168.7.5, and the destination IP address is 192.168.219.24. At which point in the network was this packet captured? leaving host A leaving ATL leaving...