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:
- As there is nothing in logcat, it smells like a platform bug
- 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
you have already specify the package name in menifest tag so don't redeclare it in activity tag, below code will work for menifest.
ReplyDelete<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"/>
Your Application and Activity objects are both named as "rands.mycompany.com.Rands" maybe that's the problem?
ReplyDelete