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

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.