views:

399

answers:

2

I have been able to create an *.apk file from my code, place the file in IIS, and download it onto a number of Android phones. Upon the install, the application works exactly as expected.

However, after a phone is rebooted, the application name is changed to the fully-qualifed java class name of the activity in the menu (so "MyActivity" becomes "com.mycompany.MyActivity"), and when I try to go to Menu > Settings, I get an error that causes android to force close my application.

Looking into DDMS, I see that I get an error indicating that it can not find my Preferences activity, despite the fact upon initial install, it works properly.

I'm using Eclipse on Windows XP, and have several Android devices at my disposal to test with.

Any idea what's going on?

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.company.app"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/logo" android:label="@string/app_name"> <!--android:debuggable="true">-->
    <activity android:name="com.company.app.ActivityMain"
              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="com.company.app.Preferences"
              android:label="@string/app_settings">
              <intent-filter>
                <category android:name="android.intent.category.PREFERENCE"></category>
                <action android:name="android.intent.action.MAIN"></action>
              </intent-filter>
    </activity>
    <service android:name="com.company.app.Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest> 
A: 

try to use this manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.company.app"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/logo" android:label="@string/app_name"> <!--android:debuggable="true">-->
    <activity android:name=".ActivityMain"
              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=".Preferences"
              android:label="@string/app_settings">
              <intent-filter>
                <category android:name="android.intent.category.PREFERENCE"></category>
                <action android:name="android.intent.action.MAIN"></action>
              </intent-filter>
    </activity>
    <service android:name=".Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
Qlimax
This resulted in the same behavior that I was seeing before. I don't think qualifying the names differently is the issue. After doing some more playing around (by creating a separate test project), it seems that everything is fine until I add another activity. Perhaps how I'm declaring these Activities is incorrect?
Brandon
+1  A: 

So I finally got this to work. I think that the package installer on the HTC Hero (and maybe the HTC Droid Eris) has some issues.

I uninstalled my application from the phone, changed the name of my main activity, and re-deployed it onto the Hero. I started to immediately get a "Force Close." I connected the device to DDMS and looked at the error. It was still looking for my old activity name. I factory reset the device and reinstalled the same package (with the updated name) and everything works as expected.

So it seems that the package installer is caching some part of the old manifest or something, not really sure what exactly is going on there. I may play with it some more if I get time.

I don't know if someone else could verify this problem, maybe it's something that should be taken up with HTC?

Brandon