Countly / countly-sdk-android

Countly Product Analytics Android SDK
https://count.ly/mobile-analytics
MIT License
680 stars 297 forks source link

Not allowed to bind to service Intent #9

Closed tracyboehrer closed 10 years ago

tracyboehrer commented 11 years ago

A small number of our users are encountering crash do to an " Not allowed to bind to service Intent" in Count.ly.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alamode.totalmobile/com.alamode.totalmobile.landing.FilesActivity}: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.drippler.android.updates/.utils.openudid.OpenUDIDService } at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) at android.app.ActivityThread.access$700(ActivityThread.java:143) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4950) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.drippler.android.updates/.utils.openudid.OpenUDIDService } at android.app.ContextImpl.bindService(ContextImpl.java:1326) at android.app.ContextImpl.bindService(ContextImpl.java:1300) at android.content.ContextWrapper.bindService(ContextWrapper.java:401) at org.OpenUDID.OpenUDID_manager.startService(OpenUDID_manager.java:107) at org.OpenUDID.OpenUDID_manager.sync(OpenUDID_manager.java:170) at ly.count.android.api.Countly.init(Countly.java:66) at com.alamode.totalmobile.landing.FilesActivity.onCreate(FilesActivity.java:69) at android.app.Activity.performCreate(Activity.java:5179) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) ... 11 more

mingfai commented 11 years ago

I saw exactly the same error in crash report. that's why I looked at the implementation and want to figure out why it needs the OpenUDID stuff that seems to make it more error prone. Refer to issue #7

ygbr commented 10 years ago

I have witnessed the same with some users (the majority using Galaxy S4 devices):

java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.darksciencemedia.p2s.android/org.OpenUDID$OpenUDID_service }
at android.app.ContextImpl.bindService(ContextImpl.java:1737)
at android.app.ContextImpl.bindService(ContextImpl.java:1708)
at android.content.ContextWrapper.bindService(ContextWrapper.java:480)
at org.OpenUDID.OpenUDID_manager.startService(OpenUDID_manager.java:105)
at org.OpenUDID.OpenUDID_manager.onServiceConnected(OpenUDID_manager.java:69)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)

and

java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.drippler.android.updates/.utils.openudid.OpenUDIDService }
at android.app.ContextImpl.bindService(ContextImpl.java:1737)
at android.app.ContextImpl.bindService(ContextImpl.java:1708)
at android.content.ContextWrapper.bindService(ContextWrapper.java:480)
at org.OpenUDID.OpenUDID_manager.startService(OpenUDID_manager.java:105)
at org.OpenUDID.OpenUDID_manager.onServiceConnected(OpenUDID_manager.java:69)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)

Any ideas on how to solve this?

mingfai commented 10 years ago

See my last comment at issue #7

lionscribe commented 10 years ago

This is really a OpenUDID code issue, but the solution is simple; Edit OpenUUID_manager.java file replace the following lines in the startService function mContext.bindService(i, this, Context.BIND_AUTO_CREATE); mMatchingIntents.remove(0); with mMatchingIntents.remove(0); try { // try added by Lionscribe mContext.bindService(i, this, Context.BIND_AUTO_CREATE); } catch (SecurityException e) { startService(); // ignore this one, and start next one }

Good Luck, Lionscribe

lionscribe commented 10 years ago

This fix has now been meged into the main branch of OpenUUID. So you can now just update OpenUUID and everything should be fine.

gorkem-cetin commented 10 years ago

Countly branch updated