无法在android中解决ANR

时间:2011-09-28 06:53:48

标签: android

我在Android设备上安装我的apk文件,安装后我点击打开按钮,我的应用程序无法启动并显示强制关闭。

我的应用程序的logcat输出如下所示:

    09-28 12:14:57.651: INFO/ActivityManager(124): Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.biz.mlm/.SplashScreen }

09-28 12:14:57.660: WARN/ActivityManager(124): Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.biz.mlm/.SplashScreen } from ProcessRecord{44ffa660 1130:com.android.packageinstaller/10026} (pid=1130, uid=10026) requires android.permission.WRITE_CONTACTS

09-28 12:14:57.672: DEBUG/AndroidRuntime(1130): Shutting down VM

09-28 12:14:57.672: WARN/dalvikvm(1130): threadid=1: thread exiting with uncaught exception (group=0x4001d800)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130): FATAL EXCEPTION: main

09-28 12:14:57.700: ERROR/AndroidRuntime(1130): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.biz.mlm/.SplashScreen } from ProcessRecord{44ffa660 1130:com.android.packageinstaller/10026} (pid=1130, uid=10026) requires android.permission.WRITE_CONTACTS

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.os.Parcel.readException(Parcel.java:1247)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.os.Parcel.readException(Parcel.java:1235)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.app.Activity.startActivityForResult(Activity.java:2817)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.app.Activity.startActivity(Activity.java:2923)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at com.android.packageinstaller.InstallAppProgress.onClick(InstallAppProgress.java:224)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.view.View.performClick(View.java:2408)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.view.View$PerformClick.run(View.java:8816)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.os.Handler.handleCallback(Handler.java:587)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.os.Handler.dispatchMessage(Handler.java:92)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.os.Looper.loop(Looper.java:123)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at java.lang.reflect.Method.invokeNative(Native Method)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at java.lang.reflect.Method.invoke(Method.java:521)

09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-28 12:14:57.700: ERROR/AndroidRuntime(1130):     at dalvik.system.NativeStart.main(Native Method)
09-28 12:14:57.740: WARN/ActivityManager(124):   Force finishing activity com.android.packageinstaller/.InstallAppProgress

请指导我做错了什么来帮助我

编辑:

我的清单中的权限是:

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <!-- <uses-permission android:name="android.permission.INSTALL_PACKAGES"/> -->
    <application android:icon="@drawable/biz_logo"
        android:permission="android.permission.WRITE_CONTACTS">

此后它也表现相同

3 个答案:

答案 0 :(得分:3)

您似乎需要添加权限

android.permission.WRITE_CONTACTS

到你的清单文件。

百里

答案 1 :(得分:1)

logcat输出包含您需要知道的所有内容: - )

您的应用程序基本上是编写联系人,但它没有权限这样做(在Android中,应用程序需要为各种操作明确授予权限)。

编辑文件AndroidManifest.xml以包含以下行/ XML元素:

<uses-permission android:name="android.permission.WRITE_CONTACTS" />

中的

<manifest>

XML元素,然后重建,重新安装并重新运行。

有关详细信息,请查看此处:http://developer.android.com/guide/topics/manifest/uses-permission-element.html

答案 2 :(得分:0)

是的,我重建了它。我的错误是我在清单<uses-permission android:name="android.permission.WRITE_CONTACTS" />中写的,也在应用程序标签内写了这样的

<application android:icon="@drawable/logo"
        android:permission="android.permission.WRITE_CONTACTS">

所以我被迫关闭了。

此权限应在清单文件中只写