Pergunta

I'm currently developing an application on Android, however after spending the day making changes to it I'm experiencing a strange problem. On my physical device when I launch the application by clicking the icon nothing happens.... I've cleared the apps data, removed it and re-installed it. If launched from the installer (by clicking 'open' after its installed) then the installer throws an expception and closes (process.android.packageinstaller, force close)?

Launching the application through adb works fine, however? (making it hard to troubleshoot)

Has anyone seen this behavior before?

Update to include more information:

This is the output from logcat:

Running the program directly on the phone:

I/ActivityManager( 1324): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS } from pid 1460
W/ActivityManager( 1324): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS } from ProcessRecord{40848e70 1460:com.android.launcher/10055} (pid=1460, uid=10055) requires com.google.android.c2dm.permission.SEND

When run from eclipse:

D/AndroidRuntime( 5138): Calling main entry com.android.commands.am.Am
I/ActivityManager( 1324): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.apics.distantsms/.DistantSMS } from pid 5138
D/AndroidRuntime( 5138): Shutting down VM
I/ActivityManager( 1324): Start proc com.apics.distantsms for activity com.apics.distantsms/.DistantSMS: pid=5146 uid=10110 gids={3003}
D/dalvikvm( 5138): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 5138): NOTE: attach of thread 'Binder Thread #3' failed
I/ActivityManager( 1324): Displayed com.apics.distantsms/.DistantSMS: +376ms

(I took the GC lines out)

My AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.apics.distantsms"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>

<!-- Only this application can receive the messages and registration result --> 
<permission android:name="com.apics.distantsms.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.apics.distantsms.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.SEND"/>


<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".DistantSMS"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <service android:enabled="true" android:name="SMSService">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT"></category>
        </intent-filter>
    </service>
    <activity android:name="SettingsActivity">
        <intent-filter>
            <category android:name="android.intent.category.PREFERENCE"></category>
            <action android:name="android.intent.action.GET_CONTENT"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.OPENABLE"></category>
        </intent-filter>
    </activity>
    <!-- Only C2DM servers can send messages for the app. If permission is not set - any other app can generate it --> 
    <receiver android:name=".C2DMReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <!-- Receive the actual message -->
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.apics.distantsms"/>
        </intent-filter>
        <!-- Receive the registration id -->
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.apics.distantsms"/>
        </intent-filter>
    </receiver>

</application>
</manifest>

Thanks again to everyone for your help.....

Alex

Update again with the output when launching the application from the menu on the emulator (note it will run fine when called from eclipse in the emulator):

I/ActivityManager(   61): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS } from pid 132
W/ActivityManager(   61): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS } from ProcessRecord{40723798 132:com.android.launcher/10021} (pid=132, uid=10021) requires com.google.android.c2dm.permission.SEND
E/Launcher(  132): Launcher does not have the permission to launch Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS }. Make sure to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity. tag=ApplicationInfo(title=Distant SMS) intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS }
E/Launcher(  132): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.apics.distantsms/.DistantSMS } from ProcessRecord{40723798 132:com.android.launcher/10021} (pid=132, uid=10021) requires com.google.android.c2dm.permission.SEND
E/Launcher(  132):  at android.os.Parcel.readException(Parcel.java:1322)
E/Launcher(  132):  at android.os.Parcel.readException(Parcel.java:1276)
E/Launcher(  132):  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1351)
E/Launcher(  132):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
E/Launcher(  132):  at android.app.Activity.startActivityForResult(Activity.java:2827)
E/Launcher(  132):  at com.android.launcher2.Launcher.startActivityForResult(Launcher.java:1078)
E/Launcher(  132):  at android.app.Activity.startActivity(Activity.java:2933)
E/Launcher(  132):  at com.android.launcher2.Launcher.startActivitySafely(Launcher.java:1498)
E/Launcher(  132):  at com.android.launcher2.AllApps2D.onItemClick(AllApps2D.java:178)
E/Launcher(  132):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/Launcher(  132):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
E/Launcher(  132):  at android.os.Handler.handleCallback(Handler.java:587)
E/Launcher(  132):  at android.os.Handler.dispatchMessage(Handler.java:92)
E/Launcher(  132):  at android.os.Looper.loop(Looper.java:130)
E/Launcher(  132):  at android.app.ActivityThread.main(ActivityThread.java:3683)
E/Launcher(  132):  at java.lang.reflect.Method.invokeNative(Native Method)
E/Launcher(  132):  at java.lang.reflect.Method.invoke(Method.java:507)
E/Launcher(  132):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/Launcher(  132):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/Launcher(  132):  at dalvik.system.NativeStart.main(Native Method)

Again thanks....

Alex

Foi útil?

Solução

This may not be the actual reason for the problem but this is what I have done in the past when dealing with application crashes that only seem to happen on my physical device i.e. not the emulator.

  • Download a logcat reader app from the app store.

I have used CatLog, its free and does the job. - https://market.android.com/details?id=com.nolanlawson.logcat&feature=search_result

  • Once you have the app, open it and click record.
  • Then go an do whatever it is which is causing the app to crash.
  • Once it has crashed go back to catlog and you can read the logs to see what happened.

That should make it easier to debug the problem.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top