开发者

Unable to resolve ANR in android

Wen i install my apk file on android device and after installation wen i hit the open button my application does not start and shows force close.

The logcat output of my application is shown below :

    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.j开发者_JS百科ava: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

Please help me by guiding me about what I have done wrong

EDIT :

The permissions in my manifest are :

<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">

After this also it is behaving same


Looks like you need to add the permission

android.permission.WRITE_CONTACTS

to your manifest file.

Barry


The logcat output has everything you need to know :-)

Your app basically is writing contacts but it does not have permissions to do so (in Android, applications need to be given permissions explicitly for various operations).

Edit the file AndroidManifest.xml to include the following line/XML element:

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

within the

<manifest>

XML element, and then rebuild, reinstall and rerun.

For more information, take a look here: http://developer.android.com/guide/topics/manifest/uses-permission-element.html


yes i rebuilt it.my mistake was i have written in manifest <uses-permission android:name="android.permission.WRITE_CONTACTS" /> and also inside the application tag like this

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

so i was getting force close.

This permission should be written only once in the manifest file

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜