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

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex